diff --git a/client/dist/completedProjects.bundle.js b/client/dist/completedProjects.bundle.js index 1071593e790b7067edcbaba8e7342ad98a307416..a96b6e4d1a967611b7261a651fe44ea3eb35018e 100644 --- a/client/dist/completedProjects.bundle.js +++ b/client/dist/completedProjects.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -206,7 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <!--<div>\\n <img class=\\\"statusImage\\\" src=\\\"\").concat(imageUrl, \"\\\" alt=\\\"Stage Image\\\">\\n </div>-->\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 24;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n // Display end date for completed projects\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCurrentProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n // Display \"Avslutat\" for completed projects\n stageDiv = document.getElementById(\"currentStageLetter\" + improvementWork.id);\n if (stageDiv) {\n if (improvementWork.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (improvementWork.currentStage == \"Plan\") {\n console.log(\"hej\");\n stageDiv.innerHTML = \"P\";\n } else if (improvementWork.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (improvementWork.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (improvementWork.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context11.next = 25;\n break;\n case 24:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 25:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); /***/ }), @@ -266,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n if (!department) {\n _context10.next = 25;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 17;\n break;\n }\n return _context10.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 26;\n break;\n case 25:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 26:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar cache = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, startGetProjects, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n startGetProjects = performance.now();\n getProjects(projectContainer, listenersLoaded, user.id);\n console.log(\"getProjects duration: \".concat(performance.now() - startGetProjects, \" ms\"));\n }\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 44;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 44;\n return improvementWorkInfo(departmentContainer, user);\n case 44:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, startGetCachedProjects, startGetImprovementWorksForUser, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n data = [];\n if (!cache[userHsaId]) {\n _context11.next = 7;\n break;\n }\n startGetCachedProjects = performance.now();\n data = cache[userHsaId];\n console.log(\"getCachedProjects duration: \".concat(performance.now() - startGetCachedProjects, \" ms\"));\n _context11.next = 13;\n break;\n case 7:\n startGetImprovementWorksForUser = performance.now();\n _context11.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 10:\n data = _context11.sent;\n cache[userHsaId] = data;\n console.log(\"getImprovementWorksForUser duration: \".concat(performance.now() - startGetImprovementWorksForUser, \" ms\"));\n case 13:\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, startGenerateHTML, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 30;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n startGenerateHTML = performance.now();\n cardHTML = card.generateHTML();\n console.log(\"GenerateHTML duration \".concat(performance.now() - startGenerateHTML, \" ms\"));\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 22;\n break;\n }\n return _context10.abrupt(\"return\");\n case 22:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 31;\n break;\n case 30:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 31:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 15:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -276,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n id: this.suggestionID\n });\n case 8:\n suggestion = _context.sent;\n console.log(suggestion); // Check if each suggestion has the 'upvotes' array\n // Check if suggestion and suggestion[0] are defined\n if (!(!suggestion || suggestion.length === 0 || !suggestion[0])) {\n _context.next = 13;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 13:\n if (!suggestion[0].upvotes.includes(user.id)) {\n _context.next = 15;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 15:\n _context.next = 21;\n break;\n case 17:\n _context.prev = 17;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 17]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, _cardId, upvoteButton, cardIdStr, _cardId2, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n if (target && target.className === \"initiateProjectButton\") {\n _cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadInitiatePage)(_cardId);\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 15;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId2 = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId2) && myIdeaCards[_cardId2])) {\n _context13.next = 15;\n break;\n }\n _card = myIdeaCards[_cardId2];\n _context13.next = 11;\n return _card.addUpvote();\n case 11:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 15:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -286,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -306,7 +306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 31;\n break;\n }\n _context4.next = 31;\n return getProjects(projectContainer, user.id);\n case 31:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction getProjects(selectElement, /*listenersLoaded:boolean,*/userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this3 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context7.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n title = project.name;\n _context6.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context6.sent;\n if (!department) {\n _context6.next = 20;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML(); //addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'homePageProjectCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context6.next = 16;\n break;\n }\n return _context6.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context6.next = 21;\n break;\n case 20:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <!--<button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n }\n case 29:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); /***/ }), @@ -316,7 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n _context5.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 10:\n aUnitArray = _context5.sent;\n _context5.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 13:\n projectLeader = _context5.sent;\n _context5.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 16:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 28;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 28:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 34:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, link, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '../initiateForbattringsarbete/initiateIdea.css';\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(link);\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); /***/ }), @@ -326,7 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n if (!completed) {\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -346,7 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n pauseRestartButton.id = 'startPauseButton';\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); /***/ }), diff --git a/client/dist/currentProjects.bundle.js b/client/dist/currentProjects.bundle.js index 97630665431e2f31e8c0b65dfd34b1bbebeb7b3d..8e0f54b502d782ff296e29b9aab295fc6c482aac 100644 --- a/client/dist/currentProjects.bundle.js +++ b/client/dist/currentProjects.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -206,7 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <!--<div>\\n <img class=\\\"statusImage\\\" src=\\\"\").concat(imageUrl, \"\\\" alt=\\\"Stage Image\\\">\\n </div>-->\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 24;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n // Display end date for completed projects\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCurrentProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n // Display \"Avslutat\" for completed projects\n stageDiv = document.getElementById(\"currentStageLetter\" + improvementWork.id);\n if (stageDiv) {\n if (improvementWork.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (improvementWork.currentStage == \"Plan\") {\n console.log(\"hej\");\n stageDiv.innerHTML = \"P\";\n } else if (improvementWork.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (improvementWork.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (improvementWork.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context11.next = 25;\n break;\n case 24:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 25:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); /***/ }), @@ -266,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n if (!department) {\n _context10.next = 25;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 17;\n break;\n }\n return _context10.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 26;\n break;\n case 25:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 26:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar cache = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, startGetProjects, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n startGetProjects = performance.now();\n getProjects(projectContainer, listenersLoaded, user.id);\n console.log(\"getProjects duration: \".concat(performance.now() - startGetProjects, \" ms\"));\n }\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 44;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 44;\n return improvementWorkInfo(departmentContainer, user);\n case 44:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, startGetCachedProjects, startGetImprovementWorksForUser, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n data = [];\n if (!cache[userHsaId]) {\n _context11.next = 7;\n break;\n }\n startGetCachedProjects = performance.now();\n data = cache[userHsaId];\n console.log(\"getCachedProjects duration: \".concat(performance.now() - startGetCachedProjects, \" ms\"));\n _context11.next = 13;\n break;\n case 7:\n startGetImprovementWorksForUser = performance.now();\n _context11.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 10:\n data = _context11.sent;\n cache[userHsaId] = data;\n console.log(\"getImprovementWorksForUser duration: \".concat(performance.now() - startGetImprovementWorksForUser, \" ms\"));\n case 13:\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, startGenerateHTML, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 30;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n startGenerateHTML = performance.now();\n cardHTML = card.generateHTML();\n console.log(\"GenerateHTML duration \".concat(performance.now() - startGenerateHTML, \" ms\"));\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 22;\n break;\n }\n return _context10.abrupt(\"return\");\n case 22:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 31;\n break;\n case 30:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 31:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 15:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -276,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n id: this.suggestionID\n });\n case 8:\n suggestion = _context.sent;\n console.log(suggestion); // Check if each suggestion has the 'upvotes' array\n // Check if suggestion and suggestion[0] are defined\n if (!(!suggestion || suggestion.length === 0 || !suggestion[0])) {\n _context.next = 13;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 13:\n if (!suggestion[0].upvotes.includes(user.id)) {\n _context.next = 15;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 15:\n _context.next = 21;\n break;\n case 17:\n _context.prev = 17;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 17]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, _cardId, upvoteButton, cardIdStr, _cardId2, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n if (target && target.className === \"initiateProjectButton\") {\n _cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadInitiatePage)(_cardId);\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 15;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId2 = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId2) && myIdeaCards[_cardId2])) {\n _context13.next = 15;\n break;\n }\n _card = myIdeaCards[_cardId2];\n _context13.next = 11;\n return _card.addUpvote();\n case 11:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 15:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -286,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -306,7 +306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 31;\n break;\n }\n _context4.next = 31;\n return getProjects(projectContainer, user.id);\n case 31:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction getProjects(selectElement, /*listenersLoaded:boolean,*/userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this3 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context7.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n title = project.name;\n _context6.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context6.sent;\n if (!department) {\n _context6.next = 20;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML(); //addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'homePageProjectCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context6.next = 16;\n break;\n }\n return _context6.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context6.next = 21;\n break;\n case 20:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <!--<button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n }\n case 29:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); /***/ }), @@ -316,7 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n _context5.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 10:\n aUnitArray = _context5.sent;\n _context5.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 13:\n projectLeader = _context5.sent;\n _context5.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 16:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 28;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 28:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 34:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, link, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '../initiateForbattringsarbete/initiateIdea.css';\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(link);\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); /***/ }), @@ -326,7 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n if (!completed) {\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -346,7 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n pauseRestartButton.id = 'startPauseButton';\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); /***/ }), diff --git a/client/dist/homePage.bundle.js b/client/dist/homePage.bundle.js index 4438157ce1dec2e3af2c4e1ba93de3ed7be4f737..92435d47a8989daee3437c22118930460adf1dc3 100644 --- a/client/dist/homePage.bundle.js +++ b/client/dist/homePage.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -206,7 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <!--<div>\\n <img class=\\\"statusImage\\\" src=\\\"\").concat(imageUrl, \"\\\" alt=\\\"Stage Image\\\">\\n </div>-->\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 24;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n // Display end date for completed projects\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCurrentProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n // Display \"Avslutat\" for completed projects\n stageDiv = document.getElementById(\"currentStageLetter\" + improvementWork.id);\n if (stageDiv) {\n if (improvementWork.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (improvementWork.currentStage == \"Plan\") {\n console.log(\"hej\");\n stageDiv.innerHTML = \"P\";\n } else if (improvementWork.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (improvementWork.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (improvementWork.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context11.next = 25;\n break;\n case 24:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 25:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); /***/ }), @@ -266,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n if (!department) {\n _context10.next = 25;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 17;\n break;\n }\n return _context10.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 26;\n break;\n case 25:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 26:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar cache = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, startGetProjects, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n startGetProjects = performance.now();\n getProjects(projectContainer, listenersLoaded, user.id);\n console.log(\"getProjects duration: \".concat(performance.now() - startGetProjects, \" ms\"));\n }\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 44;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 44;\n return improvementWorkInfo(departmentContainer, user);\n case 44:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, startGetCachedProjects, startGetImprovementWorksForUser, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n data = [];\n if (!cache[userHsaId]) {\n _context11.next = 7;\n break;\n }\n startGetCachedProjects = performance.now();\n data = cache[userHsaId];\n console.log(\"getCachedProjects duration: \".concat(performance.now() - startGetCachedProjects, \" ms\"));\n _context11.next = 13;\n break;\n case 7:\n startGetImprovementWorksForUser = performance.now();\n _context11.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 10:\n data = _context11.sent;\n cache[userHsaId] = data;\n console.log(\"getImprovementWorksForUser duration: \".concat(performance.now() - startGetImprovementWorksForUser, \" ms\"));\n case 13:\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, startGenerateHTML, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 30;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n startGenerateHTML = performance.now();\n cardHTML = card.generateHTML();\n console.log(\"GenerateHTML duration \".concat(performance.now() - startGenerateHTML, \" ms\"));\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 22;\n break;\n }\n return _context10.abrupt(\"return\");\n case 22:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 31;\n break;\n case 30:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 31:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 15:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -276,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n id: this.suggestionID\n });\n case 8:\n suggestion = _context.sent;\n console.log(suggestion); // Check if each suggestion has the 'upvotes' array\n // Check if suggestion and suggestion[0] are defined\n if (!(!suggestion || suggestion.length === 0 || !suggestion[0])) {\n _context.next = 13;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 13:\n if (!suggestion[0].upvotes.includes(user.id)) {\n _context.next = 15;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 15:\n _context.next = 21;\n break;\n case 17:\n _context.prev = 17;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 17]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, _cardId, upvoteButton, cardIdStr, _cardId2, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n if (target && target.className === \"initiateProjectButton\") {\n _cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadInitiatePage)(_cardId);\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 15;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId2 = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId2) && myIdeaCards[_cardId2])) {\n _context13.next = 15;\n break;\n }\n _card = myIdeaCards[_cardId2];\n _context13.next = 11;\n return _card.addUpvote();\n case 11:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 15:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -286,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -306,7 +306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 31;\n break;\n }\n _context4.next = 31;\n return getProjects(projectContainer, user.id);\n case 31:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction getProjects(selectElement, /*listenersLoaded:boolean,*/userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this3 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context7.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n title = project.name;\n _context6.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context6.sent;\n if (!department) {\n _context6.next = 20;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML(); //addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'homePageProjectCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context6.next = 16;\n break;\n }\n return _context6.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context6.next = 21;\n break;\n case 20:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <!--<button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n }\n case 29:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); /***/ }), @@ -316,7 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n _context5.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 10:\n aUnitArray = _context5.sent;\n _context5.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 13:\n projectLeader = _context5.sent;\n _context5.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 16:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 28;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 28:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 34:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, link, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '../initiateForbattringsarbete/initiateIdea.css';\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(link);\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); /***/ }), @@ -326,7 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n if (!completed) {\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -346,7 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n pauseRestartButton.id = 'startPauseButton';\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); /***/ }), diff --git a/client/dist/ideaBank.bundle.js b/client/dist/ideaBank.bundle.js index b00d816fdeb08aa9b1e8808d7df0b2c837708f56..451baa6308eb112f7922a839878f9ec463f1ea30 100644 --- a/client/dist/ideaBank.bundle.js +++ b/client/dist/ideaBank.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -206,7 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <!--<div>\\n <img class=\\\"statusImage\\\" src=\\\"\").concat(imageUrl, \"\\\" alt=\\\"Stage Image\\\">\\n </div>-->\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 24;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n // Display end date for completed projects\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCurrentProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n // Display \"Avslutat\" for completed projects\n stageDiv = document.getElementById(\"currentStageLetter\" + improvementWork.id);\n if (stageDiv) {\n if (improvementWork.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (improvementWork.currentStage == \"Plan\") {\n console.log(\"hej\");\n stageDiv.innerHTML = \"P\";\n } else if (improvementWork.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (improvementWork.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (improvementWork.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context11.next = 25;\n break;\n case 24:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 25:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); /***/ }), @@ -266,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n if (!department) {\n _context10.next = 25;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 17;\n break;\n }\n return _context10.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 26;\n break;\n case 25:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 26:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar cache = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, startGetProjects, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n startGetProjects = performance.now();\n getProjects(projectContainer, listenersLoaded, user.id);\n console.log(\"getProjects duration: \".concat(performance.now() - startGetProjects, \" ms\"));\n }\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 44;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 44;\n return improvementWorkInfo(departmentContainer, user);\n case 44:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, startGetCachedProjects, startGetImprovementWorksForUser, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n data = [];\n if (!cache[userHsaId]) {\n _context11.next = 7;\n break;\n }\n startGetCachedProjects = performance.now();\n data = cache[userHsaId];\n console.log(\"getCachedProjects duration: \".concat(performance.now() - startGetCachedProjects, \" ms\"));\n _context11.next = 13;\n break;\n case 7:\n startGetImprovementWorksForUser = performance.now();\n _context11.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 10:\n data = _context11.sent;\n cache[userHsaId] = data;\n console.log(\"getImprovementWorksForUser duration: \".concat(performance.now() - startGetImprovementWorksForUser, \" ms\"));\n case 13:\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, startGenerateHTML, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 30;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n startGenerateHTML = performance.now();\n cardHTML = card.generateHTML();\n console.log(\"GenerateHTML duration \".concat(performance.now() - startGenerateHTML, \" ms\"));\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 22;\n break;\n }\n return _context10.abrupt(\"return\");\n case 22:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 31;\n break;\n case 30:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 31:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 15:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -276,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n id: this.suggestionID\n });\n case 8:\n suggestion = _context.sent;\n console.log(suggestion); // Check if each suggestion has the 'upvotes' array\n // Check if suggestion and suggestion[0] are defined\n if (!(!suggestion || suggestion.length === 0 || !suggestion[0])) {\n _context.next = 13;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 13:\n if (!suggestion[0].upvotes.includes(user.id)) {\n _context.next = 15;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 15:\n _context.next = 21;\n break;\n case 17:\n _context.prev = 17;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 17]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, _cardId, upvoteButton, cardIdStr, _cardId2, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n if (target && target.className === \"initiateProjectButton\") {\n _cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadInitiatePage)(_cardId);\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 15;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId2 = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId2) && myIdeaCards[_cardId2])) {\n _context13.next = 15;\n break;\n }\n _card = myIdeaCards[_cardId2];\n _context13.next = 11;\n return _card.addUpvote();\n case 11:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 15:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -286,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -306,7 +306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 31;\n break;\n }\n _context4.next = 31;\n return getProjects(projectContainer, user.id);\n case 31:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction getProjects(selectElement, /*listenersLoaded:boolean,*/userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this3 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context7.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n title = project.name;\n _context6.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context6.sent;\n if (!department) {\n _context6.next = 20;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML(); //addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'homePageProjectCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context6.next = 16;\n break;\n }\n return _context6.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context6.next = 21;\n break;\n case 20:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <!--<button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n }\n case 29:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); /***/ }), @@ -316,7 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n _context5.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 10:\n aUnitArray = _context5.sent;\n _context5.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 13:\n projectLeader = _context5.sent;\n _context5.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 16:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 28;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 28:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 34:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, link, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '../initiateForbattringsarbete/initiateIdea.css';\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(link);\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); /***/ }), @@ -326,7 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n if (!completed) {\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -346,7 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n pauseRestartButton.id = 'startPauseButton';\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); /***/ }), diff --git a/client/dist/initiateIdea.bundle.js b/client/dist/initiateIdea.bundle.js index 2fb742453d9b68f9760c0a0276ee72e1bb787471..c40ea1e22ea8b1bdea9bdf7d5ba52d0988efc444 100644 --- a/client/dist/initiateIdea.bundle.js +++ b/client/dist/initiateIdea.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -206,7 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <!--<div>\\n <img class=\\\"statusImage\\\" src=\\\"\").concat(imageUrl, \"\\\" alt=\\\"Stage Image\\\">\\n </div>-->\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 24;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n // Display end date for completed projects\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCurrentProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n // Display \"Avslutat\" for completed projects\n stageDiv = document.getElementById(\"currentStageLetter\" + improvementWork.id);\n if (stageDiv) {\n if (improvementWork.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (improvementWork.currentStage == \"Plan\") {\n console.log(\"hej\");\n stageDiv.innerHTML = \"P\";\n } else if (improvementWork.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (improvementWork.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (improvementWork.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context11.next = 25;\n break;\n case 24:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 25:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); /***/ }), @@ -266,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n if (!department) {\n _context10.next = 25;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 17;\n break;\n }\n return _context10.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 26;\n break;\n case 25:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 26:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar cache = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, startGetProjects, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n startGetProjects = performance.now();\n getProjects(projectContainer, listenersLoaded, user.id);\n console.log(\"getProjects duration: \".concat(performance.now() - startGetProjects, \" ms\"));\n }\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 44;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 44;\n return improvementWorkInfo(departmentContainer, user);\n case 44:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, startGetCachedProjects, startGetImprovementWorksForUser, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n data = [];\n if (!cache[userHsaId]) {\n _context11.next = 7;\n break;\n }\n startGetCachedProjects = performance.now();\n data = cache[userHsaId];\n console.log(\"getCachedProjects duration: \".concat(performance.now() - startGetCachedProjects, \" ms\"));\n _context11.next = 13;\n break;\n case 7:\n startGetImprovementWorksForUser = performance.now();\n _context11.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 10:\n data = _context11.sent;\n cache[userHsaId] = data;\n console.log(\"getImprovementWorksForUser duration: \".concat(performance.now() - startGetImprovementWorksForUser, \" ms\"));\n case 13:\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, startGenerateHTML, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 30;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n startGenerateHTML = performance.now();\n cardHTML = card.generateHTML();\n console.log(\"GenerateHTML duration \".concat(performance.now() - startGenerateHTML, \" ms\"));\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 22;\n break;\n }\n return _context10.abrupt(\"return\");\n case 22:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 31;\n break;\n case 30:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 31:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 15:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -276,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n id: this.suggestionID\n });\n case 8:\n suggestion = _context.sent;\n console.log(suggestion); // Check if each suggestion has the 'upvotes' array\n // Check if suggestion and suggestion[0] are defined\n if (!(!suggestion || suggestion.length === 0 || !suggestion[0])) {\n _context.next = 13;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 13:\n if (!suggestion[0].upvotes.includes(user.id)) {\n _context.next = 15;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 15:\n _context.next = 21;\n break;\n case 17:\n _context.prev = 17;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 17]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, _cardId, upvoteButton, cardIdStr, _cardId2, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n if (target && target.className === \"initiateProjectButton\") {\n _cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadInitiatePage)(_cardId);\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 15;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId2 = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId2) && myIdeaCards[_cardId2])) {\n _context13.next = 15;\n break;\n }\n _card = myIdeaCards[_cardId2];\n _context13.next = 11;\n return _card.addUpvote();\n case 11:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 15:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -286,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -306,7 +306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 31;\n break;\n }\n _context4.next = 31;\n return getProjects(projectContainer, user.id);\n case 31:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction getProjects(selectElement, /*listenersLoaded:boolean,*/userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this3 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context7.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n title = project.name;\n _context6.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context6.sent;\n if (!department) {\n _context6.next = 20;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML(); //addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'homePageProjectCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context6.next = 16;\n break;\n }\n return _context6.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context6.next = 21;\n break;\n case 20:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <!--<button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n }\n case 29:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); /***/ }), @@ -316,7 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n _context5.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 10:\n aUnitArray = _context5.sent;\n _context5.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 13:\n projectLeader = _context5.sent;\n _context5.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 16:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 28;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 28:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 34:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, link, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '../initiateForbattringsarbete/initiateIdea.css';\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(link);\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); /***/ }), @@ -326,7 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n if (!completed) {\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -346,7 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n pauseRestartButton.id = 'startPauseButton';\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); /***/ }), diff --git a/client/dist/login.bundle.js b/client/dist/login.bundle.js index 2f3fa1229270fcd46277ebcbb25c3c4a4f831e5d..57f1ae80c0021b4238ddd95a8176006102c0855f 100644 --- a/client/dist/login.bundle.js +++ b/client/dist/login.bundle.js @@ -106,15 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -214,15 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_4__.projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -262,15 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off('click').on('click', function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off('click').on('click', function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off('click').on('click', function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll('.nav-link');\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== 'regionOstergotlandImage' && button.id !== 'log-out-button' && button.id !== 'profileDropdown' && button.id !== 'suggestionButton';\n });\n profDropButton = document.getElementById('profileDropdown');\n logoButton = document.getElementById('regionOstergotlandImage');\n logOutButton = document.getElementById('log-out-button');\n submitButton = document.getElementById('suggestionButton');\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n button.classList.add('active');\n });\n });\n if (logoButton) {\n logoButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n ideaBankButton.classList.add('active');\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off('click').on('click', function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off('click').on('click', function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off('click').on('click', function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n $(\".initiateProjectButton\").off('click').on('click', function (e) {\n e.preventDefault();\n var target = e.target;\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll('.nav-link');\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== 'regionOstergotlandImage' && button.id !== 'log-out-button' && button.id !== 'profileDropdown' && button.id !== 'suggestionButton';\n });\n profDropButton = document.getElementById('profileDropdown');\n logoButton = document.getElementById('regionOstergotlandImage');\n logOutButton = document.getElementById('log-out-button');\n submitButton = document.getElementById('suggestionButton');\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n button.classList.add('active');\n });\n });\n if (logoButton) {\n logoButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n ideaBankButton.classList.add('active');\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -280,15 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <!--<div>\\n <img class=\\\"statusImage\\\" src=\\\"\").concat(imageUrl, \"\\\" alt=\\\"Stage Image\\\">\\n </div>-->\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 24;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n // Display end date for completed projects\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCurrentProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n // Display \"Avslutat\" for completed projects\n stageDiv = document.getElementById(\"currentStageLetter\" + improvementWork.id);\n if (stageDiv) {\n if (improvementWork.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (improvementWork.currentStage == \"Plan\") {\n console.log(\"hej\");\n stageDiv.innerHTML = \"P\";\n } else if (improvementWork.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (improvementWork.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (improvementWork.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context11.next = 25;\n break;\n case 24:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 25:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -298,15 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 28;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 20;\n break;\n }\n return _context10.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 29;\n break;\n case 28:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 29:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 28;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 20;\n break;\n }\n return _context10.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 29;\n break;\n case 28:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 29:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n if (!department) {\n _context10.next = 25;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 17;\n break;\n }\n return _context10.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 26;\n break;\n case 25:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 26:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar cache = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, startGetProjects, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n startGetProjects = performance.now();\n getProjects(projectContainer, listenersLoaded, user.id);\n console.log(\"getProjects duration: \".concat(performance.now() - startGetProjects, \" ms\"));\n }\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 44;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 44;\n return improvementWorkInfo(departmentContainer, user);\n case 44:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, startGetCachedProjects, startGetImprovementWorksForUser, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n data = [];\n if (!cache[userHsaId]) {\n _context11.next = 7;\n break;\n }\n startGetCachedProjects = performance.now();\n data = cache[userHsaId];\n console.log(\"getCachedProjects duration: \".concat(performance.now() - startGetCachedProjects, \" ms\"));\n _context11.next = 13;\n break;\n case 7:\n startGetImprovementWorksForUser = performance.now();\n _context11.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 10:\n data = _context11.sent;\n cache[userHsaId] = data;\n console.log(\"getImprovementWorksForUser duration: \".concat(performance.now() - startGetImprovementWorksForUser, \" ms\"));\n case 13:\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, startGenerateHTML, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 30;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n startGenerateHTML = performance.now();\n cardHTML = card.generateHTML();\n console.log(\"GenerateHTML duration \".concat(performance.now() - startGenerateHTML, \" ms\"));\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 22;\n break;\n }\n return _context10.abrupt(\"return\");\n case 22:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 31;\n break;\n case 30:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 31:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 15:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -316,15 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest(\".upvoteButton\");\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n id: this.suggestionID\n });\n case 8:\n suggestion = _context.sent;\n console.log(suggestion); // Check if each suggestion has the 'upvotes' array\n // Check if suggestion and suggestion[0] are defined\n if (!(!suggestion || suggestion.length === 0 || !suggestion[0])) {\n _context.next = 13;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 13:\n if (!suggestion[0].upvotes.includes(user.id)) {\n _context.next = 15;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 15:\n _context.next = 21;\n break;\n case 17:\n _context.prev = 17;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 17]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, _cardId, upvoteButton, cardIdStr, _cardId2, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n if (target && target.className === \"initiateProjectButton\") {\n _cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadInitiatePage)(_cardId);\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 15;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId2 = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId2) && myIdeaCards[_cardId2])) {\n _context13.next = 15;\n break;\n }\n _card = myIdeaCards[_cardId2];\n _context13.next = 11;\n return _card.addUpvote();\n case 11:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 15:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -334,15 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n console.log(\"nu körs koden\");\n selectProjectLeaderHTML = $(\"#projectLeader\"); // loads the select type from html\n selectEmployeeHTML = $(\"#selectEmployee\"); // loads the select type from html\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 5:\n allUsers = _context.sent;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 8:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 15:\n allHospitals = _context.sent;\n _context.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 18:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -362,7 +306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 31;\n break;\n }\n _context4.next = 31;\n return (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n case 31:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n }\n case 29:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); /***/ }), @@ -372,15 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, link, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '../initiateForbattringsarbete/initiateIdea.css';\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(link);\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n _context5.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 10:\n aUnitArray = _context5.sent;\n _context5.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 13:\n projectLeader = _context5.sent;\n _context5.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 16:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 28;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 28:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 34:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -390,15 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n alert(\"hej\");\n if (!completed) {\n alert(\"not completed\");\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n alert(\"finds element\");\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-primary\");\n iterationButton.classList.add(\"btn\", \"btn-primary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n if (!completed) {\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -418,15 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n pauseRestartButton.id = 'startPauseButton';\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), diff --git a/client/dist/makeSuggestion.bundle.js b/client/dist/makeSuggestion.bundle.js index 5186406a87f393a82576ffceecefa5c1c7898a94..67fd354980e2ffb05bb63048bdcd4bd10b1b904c 100644 --- a/client/dist/makeSuggestion.bundle.js +++ b/client/dist/makeSuggestion.bundle.js @@ -106,15 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -214,15 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_4__.projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -262,15 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off('click').on('click', function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off('click').on('click', function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off('click').on('click', function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll('.nav-link');\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== 'regionOstergotlandImage' && button.id !== 'log-out-button' && button.id !== 'profileDropdown' && button.id !== 'suggestionButton';\n });\n profDropButton = document.getElementById('profileDropdown');\n logoButton = document.getElementById('regionOstergotlandImage');\n logOutButton = document.getElementById('log-out-button');\n submitButton = document.getElementById('suggestionButton');\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n button.classList.add('active');\n });\n });\n if (logoButton) {\n logoButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n ideaBankButton.classList.add('active');\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off('click').on('click', function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off('click').on('click', function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off('click').on('click', function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n $(\".initiateProjectButton\").off('click').on('click', function (e) {\n e.preventDefault();\n var target = e.target;\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll('.nav-link');\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== 'regionOstergotlandImage' && button.id !== 'log-out-button' && button.id !== 'profileDropdown' && button.id !== 'suggestionButton';\n });\n profDropButton = document.getElementById('profileDropdown');\n logoButton = document.getElementById('regionOstergotlandImage');\n logOutButton = document.getElementById('log-out-button');\n submitButton = document.getElementById('suggestionButton');\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n button.classList.add('active');\n });\n });\n if (logoButton) {\n logoButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n ideaBankButton.classList.add('active');\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -280,15 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <!--<div>\\n <img class=\\\"statusImage\\\" src=\\\"\").concat(imageUrl, \"\\\" alt=\\\"Stage Image\\\">\\n </div>-->\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 24;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n // Display end date for completed projects\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCurrentProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n // Display \"Avslutat\" for completed projects\n stageDiv = document.getElementById(\"currentStageLetter\" + improvementWork.id);\n if (stageDiv) {\n if (improvementWork.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (improvementWork.currentStage == \"Plan\") {\n console.log(\"hej\");\n stageDiv.innerHTML = \"P\";\n } else if (improvementWork.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (improvementWork.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (improvementWork.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context11.next = 25;\n break;\n case 24:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 25:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -298,15 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 28;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 20;\n break;\n }\n return _context10.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 29;\n break;\n case 28:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 29:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 28;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 20;\n break;\n }\n return _context10.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 29;\n break;\n case 28:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 29:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n if (!department) {\n _context10.next = 25;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 17;\n break;\n }\n return _context10.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 26;\n break;\n case 25:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 26:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar cache = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, startGetProjects, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n startGetProjects = performance.now();\n getProjects(projectContainer, listenersLoaded, user.id);\n console.log(\"getProjects duration: \".concat(performance.now() - startGetProjects, \" ms\"));\n }\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 44;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 44;\n return improvementWorkInfo(departmentContainer, user);\n case 44:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, startGetCachedProjects, startGetImprovementWorksForUser, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n data = [];\n if (!cache[userHsaId]) {\n _context11.next = 7;\n break;\n }\n startGetCachedProjects = performance.now();\n data = cache[userHsaId];\n console.log(\"getCachedProjects duration: \".concat(performance.now() - startGetCachedProjects, \" ms\"));\n _context11.next = 13;\n break;\n case 7:\n startGetImprovementWorksForUser = performance.now();\n _context11.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 10:\n data = _context11.sent;\n cache[userHsaId] = data;\n console.log(\"getImprovementWorksForUser duration: \".concat(performance.now() - startGetImprovementWorksForUser, \" ms\"));\n case 13:\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, startGenerateHTML, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 30;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n startGenerateHTML = performance.now();\n cardHTML = card.generateHTML();\n console.log(\"GenerateHTML duration \".concat(performance.now() - startGenerateHTML, \" ms\"));\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 22;\n break;\n }\n return _context10.abrupt(\"return\");\n case 22:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 31;\n break;\n case 30:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 31:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 15:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -316,15 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest(\".upvoteButton\");\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n id: this.suggestionID\n });\n case 8:\n suggestion = _context.sent;\n console.log(suggestion); // Check if each suggestion has the 'upvotes' array\n // Check if suggestion and suggestion[0] are defined\n if (!(!suggestion || suggestion.length === 0 || !suggestion[0])) {\n _context.next = 13;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 13:\n if (!suggestion[0].upvotes.includes(user.id)) {\n _context.next = 15;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 15:\n _context.next = 21;\n break;\n case 17:\n _context.prev = 17;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 17]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, _cardId, upvoteButton, cardIdStr, _cardId2, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n if (target && target.className === \"initiateProjectButton\") {\n _cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadInitiatePage)(_cardId);\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 15;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId2 = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId2) && myIdeaCards[_cardId2])) {\n _context13.next = 15;\n break;\n }\n _card = myIdeaCards[_cardId2];\n _context13.next = 11;\n return _card.addUpvote();\n case 11:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 15:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -334,15 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n console.log(\"nu körs koden\");\n selectProjectLeaderHTML = $(\"#projectLeader\"); // loads the select type from html\n selectEmployeeHTML = $(\"#selectEmployee\"); // loads the select type from html\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 5:\n allUsers = _context.sent;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 8:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 15:\n allHospitals = _context.sent;\n _context.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 18:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -362,7 +306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 31;\n break;\n }\n _context4.next = 31;\n return (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n case 31:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n }\n case 29:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); /***/ }), @@ -372,15 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, link, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '../initiateForbattringsarbete/initiateIdea.css';\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(link);\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n _context5.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 10:\n aUnitArray = _context5.sent;\n _context5.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 13:\n projectLeader = _context5.sent;\n _context5.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 16:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 28;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 28:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 34:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -390,15 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n alert(\"hej\");\n if (!completed) {\n alert(\"not completed\");\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n alert(\"finds element\");\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-primary\");\n iterationButton.classList.add(\"btn\", \"btn-primary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n if (!completed) {\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -418,15 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n pauseRestartButton.id = 'startPauseButton';\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), diff --git a/client/dist/pageHandler.bundle.js b/client/dist/pageHandler.bundle.js index 01695cd7ab9e87c307bc35b8b72bbae7d6b2ef77..15526d1b5215dcf5d184cdee19ece3147d4bbe80 100644 --- a/client/dist/pageHandler.bundle.js +++ b/client/dist/pageHandler.bundle.js @@ -106,15 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -214,15 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_4__.projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -262,15 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off('click').on('click', function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off('click').on('click', function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off('click').on('click', function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll('.nav-link');\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== 'regionOstergotlandImage' && button.id !== 'log-out-button' && button.id !== 'profileDropdown' && button.id !== 'suggestionButton';\n });\n profDropButton = document.getElementById('profileDropdown');\n logoButton = document.getElementById('regionOstergotlandImage');\n logOutButton = document.getElementById('log-out-button');\n submitButton = document.getElementById('suggestionButton');\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n button.classList.add('active');\n });\n });\n if (logoButton) {\n logoButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n ideaBankButton.classList.add('active');\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off('click').on('click', function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off('click').on('click', function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off('click').on('click', function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off('click').on('click', function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off('click').on('click', function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n $(\".initiateProjectButton\").off('click').on('click', function (e) {\n e.preventDefault();\n var target = e.target;\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll('.nav-link');\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== 'regionOstergotlandImage' && button.id !== 'log-out-button' && button.id !== 'profileDropdown' && button.id !== 'suggestionButton';\n });\n profDropButton = document.getElementById('profileDropdown');\n logoButton = document.getElementById('regionOstergotlandImage');\n logOutButton = document.getElementById('log-out-button');\n submitButton = document.getElementById('suggestionButton');\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n button.classList.add('active');\n });\n });\n if (logoButton) {\n logoButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener('click', function () {\n buttons.forEach(function (b) {\n return b.classList.remove('active');\n });\n ideaBankButton.classList.add('active');\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Förbättringsportalen\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(currentProjectsListenersAdded); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -280,15 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadNolanStages: () => (/* binding */ loadNolanStages),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPatientRiskLevels: () => (/* binding */ loadPatientRiskLevels),\n/* harmony export */ projectCard: () => (/* binding */ projectCard),\n/* harmony export */ sortProjects: () => (/* binding */ sortProjects)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBardiv\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 21;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n id++;\n _context11.next = 22;\n break;\n case 21:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 22:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <!--<div>\\n <img class=\\\"statusImage\\\" src=\\\"\").concat(imageUrl, \"\\\" alt=\\\"Stage Image\\\">\\n </div>-->\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, checkedWorkStatus, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context7.next = 3;\n break;\n }\n return _context7.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n checkedWorkStatus = false;\n ascendingDates = false;\n fetch(\"currentProjects/currentProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createWorkStatusCheckboxContainer = tempContainer.querySelector(\"#projectStatusSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createWorkStatusCheckboxContainer) {\n console.log(\"Checkbox container found:\", createWorkStatusCheckboxContainer);\n createWorkStatusCheckboxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var checkboxes, checkedWorkStatus;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n console.log(\"Checkbox changed\");\n checkboxes = createWorkStatusCheckboxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Use a boolean variable to store the completion status\n checkedWorkStatus = false; // Check the checkboxes to determine the completion status\n checkboxes.forEach(function (checkbox) {\n var inputCheckbox = checkbox;\n if (inputCheckbox.checked) {\n checkedWorkStatus = true;\n }\n });\n console.log(\"Filtering by completion status:\", checkedWorkStatus);\n _context5.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: checkedWorkStatus\n });\n case 7:\n filteredImprovementWorks = _context5.sent;\n console.log(\"Filtered improvementWorks after applying completion status filter:\", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n } else {\n console.error(\"Checkbox container not found!\");\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context7.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 13:\n filteredImprovementWorks = _context7.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n loadWorkStatus();\n case 25:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction loadWorkStatus() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var selectWorkStatusHTML, allWorkStatus;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n selectWorkStatusHTML = $(\"#projectStatusSelection\");\n allWorkStatus = [\"Visa avslutade\"];\n allWorkStatus.forEach(function (completed) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + completed + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + completed + \"</label>\\n </div>\");\n selectWorkStatusHTML.append(generatedElement);\n console.log(\"Adding HTML for for completed \", completed);\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(card.projectId, card);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var title, department, projectLeader, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n title = improvementWork.name;\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context11.sent;\n _context11.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeader = _context11.sent;\n if (!department) {\n _context11.next = 24;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context11.next = 16;\n break;\n }\n return _context11.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(improvementWork.id, card);\n // Display end date for completed projects\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCurrentProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n // Display \"Avslutat\" for completed projects\n stageDiv = document.getElementById(\"currentStageLetter\" + improvementWork.id);\n if (stageDiv) {\n if (improvementWork.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (improvementWork.currentStage == \"Plan\") {\n console.log(\"hej\");\n stageDiv.innerHTML = \"P\";\n } else if (improvementWork.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (improvementWork.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (improvementWork.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context11.next = 25;\n break;\n case 24:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 25:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n case 3:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n $(\"#ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n $(\"#project-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context14.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\") || element.classList.contains(\"toSinglePage\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n case 2:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = false;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n _context16.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 10:\n filteredImprovementWorks = _context16.sent;\n _context16.next = 13;\n return getProjects(container, true, filteredImprovementWorks);\n case 13:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -298,15 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 28;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 20;\n break;\n }\n return _context10.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 29;\n break;\n case 28:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 29:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 28;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 20;\n break;\n }\n return _context10.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 29;\n break;\n case 28:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 29:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context5.next = 39;\n break;\n }\n _context5.next = 39;\n return getProjects(projectContainer, listenersLoaded, user.id);\n case 39:\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 46;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 46;\n return improvementWorkInfo(departmentContainer, user);\n case 46:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context11.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, name, description, i, dateStarted, card, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_2__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n if (!department) {\n _context10.next = 25;\n break;\n }\n name = \"Ansvarig\"; //Waiting for backend fix\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 17;\n break;\n }\n return _context10.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"D\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 26;\n break;\n case 25:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 26:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 5:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addEventListener: () => (/* binding */ addEventListener),\n/* harmony export */ getProjects: () => (/* binding */ getProjects),\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert(\"logout\");\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_1__.logout)();\n}\nvar myIdeaCards = {};\nvar cache = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\"> \").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n addListner(userSuggestions, container);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch(\"homePage.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this3 = this;\n var tempContainer, specificElement, inputNotes, _tmp, uid, _user, userNotes, tmp, user, suggestionContainer, nameHeaderElement, userFullName, projectContainer, startGetProjects, departmentContainer, departmentDiv;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector(\".main-content\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n inputNotes = document.getElementById(\"input-text-notes\");\n if (!inputNotes) {\n _context5.next = 20;\n break;\n }\n console.log(\"InputNotes exist\");\n _tmp = localStorage.getItem(\"user\");\n if (_tmp) {\n _context5.next = 11;\n break;\n }\n console.log(\"There is not a user in localStorage\");\n return _context5.abrupt(\"return\");\n case 11:\n uid = JSON.parse(_tmp)[0].uid;\n _context5.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 14:\n _user = _context5.sent;\n userNotes = _user[0].notes; // Set the value of the input box\n inputNotes.value = userNotes || \"\";\n inputNotes.addEventListener(\"input\", function () {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var inputNotesValue;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n inputNotesValue = inputNotes.value;\n _context4.prev = 1;\n if (!_user[0].id) {\n _context4.next = 6;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.addNoteToUser)(_user[0].id, inputNotesValue);\n case 5:\n console.log(\"Saved notes\");\n case 6:\n _context4.next = 11;\n break;\n case 8:\n _context4.prev = 8;\n _context4.t0 = _context4[\"catch\"](1);\n console.log(\"Error saving notes\", _context4.t0);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[1, 8]]);\n }));\n });\n _context5.next = 21;\n break;\n case 20:\n console.log(\"No notes to be saved\");\n case 21:\n tmp = localStorage.getItem(\"user\");\n console.log(tmp);\n if (tmp) {\n _context5.next = 26;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context5.abrupt(\"return\");\n case 26:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context5.next = 32;\n break;\n }\n _context5.next = 31;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 31:\n addListner(myIdeaCards, container);\n case 32:\n nameHeaderElement = document.getElementById(\"user-name-header\");\n userFullName = user.firstName + \" \" + user.lastName;\n if (nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n startGetProjects = performance.now();\n getProjects(projectContainer, listenersLoaded, user.id);\n console.log(\"getProjects duration: \".concat(performance.now() - startGetProjects, \" ms\"));\n }\n console.log(\"innan\");\n departmentContainer = document.getElementById(\"department-container\");\n departmentDiv = document.getElementById(\"nolanAct\");\n if (!(departmentContainer && document.getElementById(\"nolanAct\") && departmentDiv.innerHTML.trim() === \"\")) {\n _context5.next = 44;\n break;\n }\n console.log(\"anropar funktionen\");\n _context5.next = 44;\n return improvementWorkInfo(departmentContainer, user);\n case 44:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 4:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction addEventListener(projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n $(\"#homepage-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context7.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\n/*\nasync function performSearch(searchBar: HTMLInputElement, container: HTMLElement) {\n let inputValue = searchBar.value;\n //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n\n let query: { [key: string]: string } = {};\n\n removeCardsFromDiv(\"div.projectCardCardDiv\");\n \n if (inputValue !== \"\") {\n const matchedStage = Object.keys(nolanStageMapping).find((stage) =>\n stage.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n filteredImprovementWorks = await getImprovementWorks(query);\n await getProjects(container, true, filteredImprovementWorks);\n}\n*/\nfunction improvementWorkInfo(departmentContainer, user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var improvementWorks, improvementWorksPlan, improvementWorksDo, improvementWorkStudy, improvementWorksAct, _iterator, _step, improvementWork, improvementWorkContainer, improvementWorkContainerElement, nolanAct, actElement, nolanPlan, planElement, nolanDo, doElement, nolanStudy, studyElement;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n unitId: user.unitId\n });\n case 2:\n improvementWorks = _context9.sent;\n console.log(\"i funktionen\");\n //Count number of improvement works in the department in each stage\n improvementWorksPlan = 0;\n improvementWorksDo = 0;\n improvementWorkStudy = 0;\n improvementWorksAct = 0;\n _iterator = _createForOfIteratorHelper(improvementWorks);\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n improvementWork = _step.value;\n if (improvementWork.currentStage == \"Plan\") {\n improvementWorksPlan += 1;\n } else if (improvementWork.currentStage == \"Do\") {\n improvementWorksDo += 1;\n } else if (improvementWork.currentStage == \"Study\") {\n improvementWorkStudy += 1;\n } else if (improvementWork.currentStage == \"Act\") {\n improvementWorksAct += 1;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n improvementWorkContainer = document.getElementById(\"numberOfImprovementWorks\"); //Append a div displaying the number of improvement works in the user's department\n improvementWorkContainerElement = document.createElement(\"p\");\n improvementWorkContainerElement.innerHTML = \"Antal pågående förbättringsarbeten i din avdelning: \" + improvementWorks.length;\n if (improvementWorkContainer && improvementWorkContainer.innerHTML.trim() === \"\") {\n improvementWorkContainer.appendChild(improvementWorkContainerElement);\n }\n //Append the text displaying the number of improvement works that are in the stage act\n nolanAct = document.getElementById(\"nolanAct\");\n actElement = document.createElement(\"p\");\n actElement.innerHTML = \"Agera: \" + improvementWorksAct;\n actElement.style.margin = \"5px\";\n if (nolanAct) {\n nolanAct.appendChild(actElement);\n }\n //Append the text displaying the number of improvement works that are in the stage plan\n nolanPlan = document.getElementById(\"nolanPlan\");\n planElement = document.createElement(\"p\");\n planElement.innerHTML = \"Planera: \" + improvementWorksPlan;\n planElement.style.margin = \"5px\";\n if (nolanPlan) {\n nolanPlan.appendChild(planElement);\n }\n //Append the text displaying the number of improvement works that are in the stage do\n nolanDo = document.getElementById(\"nolanDo\");\n doElement = document.createElement(\"p\");\n doElement.innerHTML = \"Göra: \" + improvementWorksDo;\n doElement.style.margin = \"5px\";\n if (nolanDo) {\n nolanDo.appendChild(doElement);\n }\n //Append the text displaying the number of improvement works that are in the stage study\n nolanStudy = document.getElementById(\"nolanStudy\");\n studyElement = document.createElement(\"p\");\n studyElement.innerHTML = \"Studera: \" + improvementWorkStudy;\n studyElement.style.margin = \"5px\";\n if (nolanStudy) {\n nolanStudy.appendChild(studyElement);\n }\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var _this4 = this;\n var data, startGetCachedProjects, startGetImprovementWorksForUser, id;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n data = [];\n if (!cache[userHsaId]) {\n _context11.next = 7;\n break;\n }\n startGetCachedProjects = performance.now();\n data = cache[userHsaId];\n console.log(\"getCachedProjects duration: \".concat(performance.now() - startGetCachedProjects, \" ms\"));\n _context11.next = 13;\n break;\n case 7:\n startGetImprovementWorksForUser = performance.now();\n _context11.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorksForUser)(userHsaId);\n case 10:\n data = _context11.sent;\n cache[userHsaId] = data;\n console.log(\"getImprovementWorksForUser duration: \".concat(performance.now() - startGetImprovementWorksForUser, \" ms\"));\n case 13:\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var title, department, responsible, name, description, i, dateStarted, card, startGenerateHTML, cardHTML, div, datesDiv, stageDiv;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n title = project.name;\n _context10.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 3:\n department = _context10.sent;\n _context10.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(project.id);\n case 6:\n responsible = _context10.sent;\n if (!department) {\n _context10.next = 30;\n break;\n }\n name = responsible.firstName + \" \" + responsible.lastName;\n description = project.content;\n i = id;\n dateStarted = project.dateStarted;\n card = new projectCard(i, name, department.name, title, description, project.id, dateStarted);\n projectCards[i] = card;\n startGenerateHTML = performance.now();\n cardHTML = card.generateHTML();\n console.log(\"GenerateHTML duration \".concat(performance.now() - startGenerateHTML, \" ms\"));\n div = document.createElement(\"div\");\n div.className = \"homePageProjectCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context10.next = 22;\n break;\n }\n return _context10.abrupt(\"return\");\n case 22:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(project.id, card);\n if (project.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesHomePage\" + project.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(project.endDate);\n }\n }\n stageDiv = document.getElementById(\"currentStageLetterHomePage\" + project.id);\n if (stageDiv) {\n if (project.completed) {\n stageDiv.innerText = \"Avslutat\";\n stageDiv.style.fontSize = \"25px\";\n stageDiv.style.marginLeft = \"5px\";\n stageDiv.style.marginTop = \"30px\";\n } else if (project.currentStage == \"Plan\") {\n stageDiv.innerHTML = \"P\";\n } else if (project.currentStage == \"Do\") {\n stageDiv.innerHTML = \"G\";\n } else if (project.currentStage == \"Study\") {\n stageDiv.innerText = \"S\";\n } else if (project.currentStage == \"Act\") {\n stageDiv.innerText = \"A\";\n }\n }\n id++;\n _context10.next = 31;\n break;\n case 30:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 31:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n });\n case 15:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.dateStarted = dateStarted;\n //this.endDate = endDate;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"homepage-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterHomePage\").concat(this.projectId, \"\\\" style=\\\"font-size: 50px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 35px; margin-top: 10px;\\\"></div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" style=\\\"font-style: italic; margin-top: 5px;\\\" id=\\\"ongoingCardDatesHomePage\").concat(this.projectId, \"\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n\\n <!--<button id=\\\"homepage-project-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n \\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"homepage-expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"homepage-expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}(); //<p id=\"homepage-ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -316,15 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest(\".upvoteButton\");\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n id: this.suggestionID\n });\n case 8:\n suggestion = _context.sent;\n console.log(suggestion); // Check if each suggestion has the 'upvotes' array\n // Check if suggestion and suggestion[0] are defined\n if (!(!suggestion || suggestion.length === 0 || !suggestion[0])) {\n _context.next = 13;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 13:\n if (!suggestion[0].upvotes.includes(user.id)) {\n _context.next = 15;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 15:\n _context.next = 21;\n break;\n case 17:\n _context.prev = 17;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 17]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 6:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!checkedUnitIds) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n _context10.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 26:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 28:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator2, _step2, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator2.s();\n case 6:\n if ((_step2 = _iterator2.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step2.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator2.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator2.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, upvoteButton, cardIdStr, _cardId, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 14;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId) && myIdeaCards[_cardId])) {\n _context13.next = 14;\n break;\n }\n _card = myIdeaCards[_cardId];\n _context13.next = 10;\n return _card.addUpvote();\n case 10:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector('svg');\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector('.upvoteNumber');\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 14:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator3, _step3, suggestion, users, spaceIndex, firstName, lastName, _iterator4, _step4, user, _iterator5, _step5, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator3 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator3.s();\n case 14:\n if ((_step3 = _iterator3.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step3.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator3.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator3.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator4 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator4.s();\n case 43:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step4.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator4.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator4.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator5.s();\n case 66:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step5.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator5.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator5.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearContent: () => (/* binding */ clearContent),\n/* harmony export */ loadHospitals: () => (/* binding */ loadHospitals),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadUnits: () => (/* binding */ loadUnits),\n/* harmony export */ removeCardsFromDiv: () => (/* binding */ removeCardsFromDiv),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\n// Initialize filtered suggestions as empty array (potentially change to get all suggestions\nvar filteredSuggestions = [];\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID, dateCreated) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n this.dateCreated = dateCreated;\n }\n // <img src=\"images/upvoteIcon.png\" class =\"upvoteIcon\" alt=\"upvoteIcon\">\n _createClass(IdeaCard, [{\n key: \"hasUserUpvoted\",\n value: function hasUserUpvoted() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var tmp, user, suggestion;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context.next = 4;\n break;\n }\n console.log(\"No user in localStorage\");\n return _context.abrupt(\"return\", false);\n case 4:\n user = JSON.parse(tmp)[0];\n _context.prev = 5;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", this.suggestionID);\n case 8:\n _context.next = 10;\n return _context.sent;\n case 10:\n suggestion = _context.sent;\n if (!(!suggestion || suggestion.length === 0)) {\n _context.next = 14;\n break;\n }\n console.error(\"Suggestion not found or is invalid\");\n return _context.abrupt(\"return\", false);\n case 14:\n if (!suggestion.upvotes.includes(user.id)) {\n _context.next = 16;\n break;\n }\n return _context.abrupt(\"return\", true);\n case 16:\n _context.next = 22;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](5);\n console.error(\"Error in hasUserUpvoted: \", _context.t0);\n return _context.abrupt(\"return\", false);\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[5, 18]]);\n }));\n }\n }, {\n key: \"addUpvote\",\n value: function addUpvote() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var tmp, user, upvoted;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n tmp = localStorage.getItem(\"user\");\n if (tmp) {\n _context2.next = 4;\n break;\n }\n console.log(\"there is not a user in localStorage\");\n return _context2.abrupt(\"return\");\n case 4:\n user = JSON.parse(tmp)[0];\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.upvoteSuggestion)(this.suggestionID, user.id);\n case 7:\n upvoted = _context2.sent;\n if (upvoted) {\n this.upvoteCount++;\n } else {\n this.upvoteCount--;\n }\n return _context2.abrupt(\"return\", upvoted);\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var userHasUpvoted, upvoteColor, strokeColor;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return this.hasUserUpvoted();\n case 2:\n userHasUpvoted = _context3.sent;\n upvoteColor = userHasUpvoted ? \"purple\" : \"white\";\n strokeColor = userHasUpvoted ? \"purple\" : \"grey\";\n return _context3.abrupt(\"return\", \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \" \").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_1__.formatDate)(this.dateCreated), \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n \\n <div class=\\\"upvoteDiv\\\">\\n <button class=\\\"upvoteButton\\\" id=\\\"upvoteButton\").concat(this.id, \"\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" stroke=\\\"\").concat(strokeColor, \"\\\" fill=\\\"\").concat(upvoteColor, \"\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 24 24\\\">\\n <path d=\\\"M18 7.2071C18 6.09347 16.6536 5.53575 15.8661 6.32321L6.32321 15.8661C5.53576 16.6536 6.09346 18 7.2071 18H16.25C17.2165 18 18 17.2165 18 16.25V7.2071Z\\\" transform=\\\"rotate(225 12 12)\\\"/>\\n </svg>\\n <div class=\\\"ideaCardFont upvoteNumber\\\">\").concat(this.upvoteCount, \"</div>\\n </button>\\n</div>\\n\\n </div>\\n </div>\\n </div>\\n \\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFontComments\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <button class=\\\"ideaCardFontComments\\\" id=\\\"commentsProjectCard\\\">Kommentarer</button>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera F\\xF6rb\\xE4ttringsf\\xF6rslag</button>\\n </div>\\n\\n <!-- commentsModal.html -->\\n <div id=\\\"commentsModal\\\" class=\\\"modal\\\">\\n <div class=\\\"modal-content\\\">\\n <span class=\\\"close\\\" id=\\\"closeModal\\\">×</span>\\n <div id=\\\"existingComments\\\">\\n <!-- Display existing comments here -->\\n <div class=\\\"comment-container\\\">\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">John Doe</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n \\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Jane Smith</div>\\n <div class=\\\"comment-text\\\">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\\n </div>\\n\\n <div class=\\\"comment\\\">\\n <div class=\\\"comment-author\\\">Erik Svensson</div>\\n <div class=\\\"comment-text\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>\\n </div>\\n </div>\\n </div>\\n <form id=\\\"addCommentForm\\\">\\n <input type=\\\"text\\\" id=\\\"commentInput\\\" name=\\\"commentInput\\\">\\n <button type=\\\"button\\\" id=\\\"addCommentBtn\\\">Publicera</button>\\n </form>\\n </div>\\n </div>\\n </div>\\n </div>\\n </div>\"));\n case 6:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n }\n }, {\n key: \"openCommentsModal\",\n value: function openCommentsModal() {\n var _this = this;\n // Retrieve existing comments and display in the modal\n var existingCommentsContainer = document.getElementById(\"existingComments\");\n // Logic to fetch and display existing comments goes here...\n // Show the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.classList.add(\"show-modal\");\n modal.style.display = \"block\";\n // Add click event listener for the close button\n var closeButton = modal.querySelector(\"#closeModal\");\n if (closeButton) {\n closeButton.addEventListener(\"click\", function () {\n _this.closeCommentsModal();\n });\n }\n var publishButton = modal.querySelector(\"#addCommentBtn\");\n if (publishButton) {\n publishButton.addEventListener(\"click\", function () {\n alert(\"Kul att du vill kommentera det här förbättringsförslaget! Vi har ännu inte implementerat kommentarsfältet så kommentarerna du ser är hårdkodade av oss.\");\n });\n }\n }\n }\n }, {\n key: \"closeCommentsModal\",\n value: function closeCommentsModal() {\n // Close the comments modal\n var modal = document.getElementById(\"commentsModal\");\n if (modal) {\n modal.style.display = \"none\";\n modal.classList.remove(\"show-modal\");\n }\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = \"../client/projectPage/projectPageP.html\";\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, suggestions) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var counter;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context4.sent;\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context4.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id, suggestion.dateCreated);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n case 2:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID, dateCreated) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var card, cardHTML, div, commentsButton;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID, dateCreated);\n _context6.next = 3;\n return card.generateHTML();\n case 3:\n cardHTML = _context6.sent;\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n // Add click event listener for \"Kommentarer\" button\n commentsButton = div.querySelector(\"#commentsProjectCard\");\n if (commentsButton) {\n commentsButton.addEventListener(\"click\", function (event) {\n // Handle the click event, e.g., open the comments modal\n card.openCommentsModal();\n });\n }\n container.appendChild(div);\n case 11:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var container, scriptElement, checkedHospitalIds, checkedUnitIds, searchBar;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context9.next = 3;\n break;\n }\n return _context9.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n _context7.next = 5;\n return getFilteredSuggestions(undefined, checkedHospitalIds);\n case 5:\n filteredSuggestions = _context7.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n // Future change: Only clear the unitIds for unchecked hospitals!\n clearContent(\"unitSelection\");\n loadUnits(checkedHospitalIds);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n // Log all checked unit IDs\n _context8.next = 5;\n return getFilteredSuggestions(checkedUnitIds);\n case 5:\n filteredSuggestions = _context8.sent;\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 8:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context9.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 12:\n filteredSuggestions = _context9.sent;\n console.log(\"Filtered suggestions: \", filteredSuggestions);\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n _context9.next = 17;\n return createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 17:\n addListner(myIdeaCards, container);\n searchBar = document.getElementById(\"searchBarId\");\n searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar);\n }\n });\n loadHospitals();\n case 21:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n}\nfunction getFilteredSuggestions(checkedUnitIds, checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestions, _iterator, _step, checkedUnitId, allSuggestionsOfUnit, _iterator2, _step2, checkedHospital, allSuggestionsOfhospital;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n suggestions = [];\n if (!(checkedUnitIds === null || checkedUnitIds === void 0 ? void 0 : checkedUnitIds.length)) {\n _context10.next = 24;\n break;\n }\n _iterator = _createForOfIteratorHelper(checkedUnitIds);\n _context10.prev = 3;\n _iterator.s();\n case 5:\n if ((_step = _iterator.n()).done) {\n _context10.next = 13;\n break;\n }\n checkedUnitId = _step.value;\n _context10.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n unitId: checkedUnitId\n });\n case 9:\n allSuggestionsOfUnit = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfUnit);\n case 11:\n _context10.next = 5;\n break;\n case 13:\n _context10.next = 18;\n break;\n case 15:\n _context10.prev = 15;\n _context10.t0 = _context10[\"catch\"](3);\n _iterator.e(_context10.t0);\n case 18:\n _context10.prev = 18;\n _iterator.f();\n return _context10.finish(18);\n case 21:\n return _context10.abrupt(\"return\", suggestions);\n case 24:\n if (!(checkedHospitalIds === null || checkedHospitalIds === void 0 ? void 0 : checkedHospitalIds.length)) {\n _context10.next = 48;\n break;\n }\n _iterator2 = _createForOfIteratorHelper(checkedHospitalIds);\n _context10.prev = 26;\n _iterator2.s();\n case 28:\n if ((_step2 = _iterator2.n()).done) {\n _context10.next = 36;\n break;\n }\n checkedHospital = _step2.value;\n _context10.next = 32;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n departmentId: checkedHospital\n });\n case 32:\n allSuggestionsOfhospital = _context10.sent;\n suggestions = suggestions.concat(allSuggestionsOfhospital);\n case 34:\n _context10.next = 28;\n break;\n case 36:\n _context10.next = 41;\n break;\n case 38:\n _context10.prev = 38;\n _context10.t1 = _context10[\"catch\"](26);\n _iterator2.e(_context10.t1);\n case 41:\n _context10.prev = 41;\n _iterator2.f();\n return _context10.finish(41);\n case 44:\n console.log(\"efter\");\n return _context10.abrupt(\"return\", suggestions);\n case 48:\n _context10.next = 50;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 50:\n suggestions = _context10.sent;\n return _context10.abrupt(\"return\", suggestions);\n case 52:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[3, 15, 18, 21], [26, 38, 41, 44]]);\n }));\n}\nfunction loadHospitals() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var selectHospitalHTML, allHospitals;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n selectHospitalHTML = $(\"#hospitalSelection\"); // loads the select type from html\n _context11.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 3:\n allHospitals = _context11.sent;\n console.log(allHospitals);\n allHospitals.forEach(function (hospital) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + hospital.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + hospital.name + \"</label>\\n </div>\");\n selectHospitalHTML.append(generatedElement);\n console.log(\"Adding HTML for for hospital \", hospital.id);\n });\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n}\nfunction loadUnits(checkedHospitalIds) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var selectUnitHTML, allUnits, _iterator3, _step3, checkedHospitalId, allUnitsOfHospital;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n selectUnitHTML = $(\"#unitSelection\"); // loads the select type from html\n allUnits = [];\n if (!(checkedHospitalIds.length != 0)) {\n _context12.next = 22;\n break;\n }\n _iterator3 = _createForOfIteratorHelper(checkedHospitalIds);\n _context12.prev = 4;\n _iterator3.s();\n case 6:\n if ((_step3 = _iterator3.n()).done) {\n _context12.next = 14;\n break;\n }\n checkedHospitalId = _step3.value;\n _context12.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n hospitalId: checkedHospitalId\n });\n case 10:\n allUnitsOfHospital = _context12.sent;\n allUnits = allUnits.concat(allUnitsOfHospital);\n case 12:\n _context12.next = 6;\n break;\n case 14:\n _context12.next = 19;\n break;\n case 16:\n _context12.prev = 16;\n _context12.t0 = _context12[\"catch\"](4);\n _iterator3.e(_context12.t0);\n case 19:\n _context12.prev = 19;\n _iterator3.f();\n return _context12.finish(19);\n case 22:\n allUnits.forEach(function (unit) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + unit.id + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + unit.name + \"</label>\\n </div>\");\n selectUnitHTML.append(generatedElement);\n console.log(\"Adding HTML for for unit \", unit.id);\n });\n case 23:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[4, 16, 19, 22]]);\n }));\n}\nfunction clearContent(id) {\n var container = document.getElementById(id);\n while (container.firstChild) {\n container.removeChild(container.firstChild);\n }\n}\nfunction addListner(cardArray, element) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n element.addEventListener(\"click\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var target, cardId, card, expandedDiv, _cardId, upvoteButton, cardIdStr, _cardId2, _card, upvoted, svg, upvoteNumberElement;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n target = event.target; //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n console.log(\"fel Div\");\n cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n card = cardArray[cardId];\n expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n if (target && target.className === \"initiateProjectButton\") {\n _cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_2__.loadInitiatePage)(_cardId);\n }\n upvoteButton = target.closest('.upvoteButton');\n if (!upvoteButton) {\n _context13.next = 15;\n break;\n }\n cardIdStr = upvoteButton.id.replace(\"upvoteButton\", \"\");\n _cardId2 = parseInt(cardIdStr, 10); // Check if the cardId is a valid number\n if (!(!isNaN(_cardId2) && myIdeaCards[_cardId2])) {\n _context13.next = 15;\n break;\n }\n _card = myIdeaCards[_cardId2];\n _context13.next = 11;\n return _card.addUpvote();\n case 11:\n upvoted = _context13.sent;\n console.log(\"upvoted :\", upvoted);\n svg = upvoteButton.querySelector(\"svg\");\n if (svg) {\n if (upvoted) {\n svg.setAttribute(\"fill\", \"purple\");\n svg.setAttribute(\"stroke\", \"purple\");\n } else {\n svg.setAttribute(\"stroke\", \"grey\");\n svg.setAttribute(\"fill\", \"white\");\n }\n upvoteNumberElement = upvoteButton.querySelector(\".upvoteNumber\");\n if (upvoteNumberElement) {\n upvoteNumberElement.textContent = _card.upvoteCount.toString(); // Assuming card.upvoteCount holds the new count\n }\n }\n case 15:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n });\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\nfunction removeCardsFromDiv(divName) {\n //Remove current elements\n var elementsToRemove = document.querySelectorAll(divName);\n // Remove each element\n elementsToRemove.forEach(function (element) {\n element.remove();\n });\n myIdeaCards = {};\n}\nfunction performSearch(searchBar) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var inputValue, container, suggestions, suggestionName, _iterator4, _step4, suggestion, users, spaceIndex, firstName, lastName, _iterator5, _step5, user, _iterator6, _step6, _user;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n inputValue = searchBar.value;\n console.log(\"Search query:\", inputValue);\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context15.next = 5;\n break;\n }\n return _context15.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n removeCardsFromDiv(\"div.IdeaCardDiv\");\n if (!(inputValue != \"\")) {\n _context15.next = 92;\n break;\n }\n _context15.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 9:\n suggestions = _context15.sent;\n suggestionName = false;\n _iterator4 = _createForOfIteratorHelper(suggestions);\n _context15.prev = 12;\n _iterator4.s();\n case 14:\n if ((_step4 = _iterator4.n()).done) {\n _context15.next = 24;\n break;\n }\n suggestion = _step4.value;\n if (!(suggestion.name.toLowerCase() >= inputValue.toLowerCase() && suggestion.name.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 22;\n break;\n }\n suggestionName = true;\n _context15.next = 20;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n name: suggestion.name\n });\n case 20:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 22:\n _context15.next = 14;\n break;\n case 24:\n _context15.next = 29;\n break;\n case 26:\n _context15.prev = 26;\n _context15.t0 = _context15[\"catch\"](12);\n _iterator4.e(_context15.t0);\n case 29:\n _context15.prev = 29;\n _iterator4.f();\n return _context15.finish(29);\n case 32:\n if (suggestionName) {\n _context15.next = 90;\n break;\n }\n _context15.next = 35;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 35:\n users = _context15.sent;\n spaceIndex = inputValue.indexOf(\" \"); //If the search is for first and last name\n if (!(spaceIndex !== -1)) {\n _context15.next = 63;\n break;\n }\n firstName = inputValue.substring(0, spaceIndex).toLowerCase();\n lastName = inputValue.substring(spaceIndex + 1).toLowerCase();\n _iterator5 = _createForOfIteratorHelper(users);\n _context15.prev = 41;\n _iterator5.s();\n case 43:\n if ((_step5 = _iterator5.n()).done) {\n _context15.next = 53;\n break;\n }\n user = _step5.value;\n if (!(user.firstName.toLowerCase() >= firstName && user.firstName.toLowerCase() <= firstName + \"~\")) {\n _context15.next = 51;\n break;\n }\n if (!(user.lastName.toLowerCase() >= lastName && user.lastName.toLowerCase() <= lastName + \"~\")) {\n _context15.next = 51;\n break;\n }\n _context15.next = 49;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 49:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 51:\n _context15.next = 43;\n break;\n case 53:\n _context15.next = 58;\n break;\n case 55:\n _context15.prev = 55;\n _context15.t1 = _context15[\"catch\"](41);\n _iterator5.e(_context15.t1);\n case 58:\n _context15.prev = 58;\n _iterator5.f();\n return _context15.finish(58);\n case 61:\n _context15.next = 90;\n break;\n case 63:\n //If the search is for only first or last name\n _iterator6 = _createForOfIteratorHelper(users);\n _context15.prev = 64;\n _iterator6.s();\n case 66:\n if ((_step6 = _iterator6.n()).done) {\n _context15.next = 82;\n break;\n }\n _user = _step6.value;\n if (!(_user.firstName.toLowerCase() >= inputValue.toLowerCase() && _user.firstName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 75;\n break;\n }\n _context15.next = 71;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 71:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n _context15.next = 80;\n break;\n case 75:\n if (!(_user.lastName.toLowerCase() >= inputValue.toLowerCase() && _user.lastName.toLowerCase() <= inputValue.toLowerCase() + \"~\")) {\n _context15.next = 80;\n break;\n }\n _context15.next = 78;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({\n creatorHsaId: _user.id\n });\n case 78:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 80:\n _context15.next = 66;\n break;\n case 82:\n _context15.next = 87;\n break;\n case 84:\n _context15.prev = 84;\n _context15.t2 = _context15[\"catch\"](64);\n _iterator6.e(_context15.t2);\n case 87:\n _context15.prev = 87;\n _iterator6.f();\n return _context15.finish(87);\n case 90:\n _context15.next = 96;\n break;\n case 92:\n _context15.next = 94;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 94:\n filteredSuggestions = _context15.sent;\n createNewCards(\"IdeaCardDiv\", container, filteredSuggestions);\n case 96:\n addListner(myIdeaCards, container);\n case 97:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[12, 26, 29, 32], [41, 55, 58, 61], [64, 84, 87, 90]]);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -334,15 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n console.log(\"nu körs koden\");\n selectProjectLeaderHTML = $(\"#projectLeader\"); // loads the select type from html\n selectEmployeeHTML = $(\"#selectEmployee\"); // loads the select type from html\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 5:\n allUsers = _context.sent;\n _context.next = 8;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 8:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 15:\n allHospitals = _context.sent;\n _context.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 18:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 20:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('#initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector('#createProjectFromSuggestionButton');\n var selectEmployeeChangeSection = tempContainer.querySelector('#selectEmployee');\n if (createButton) {\n createButton.addEventListener('click', function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" \n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values \n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ assignedEmployer: () => (/* binding */ assignedEmployer),\n/* harmony export */ getSelectedEmployees: () => (/* binding */ getSelectedEmployees),\n/* harmony export */ loadEmployees: () => (/* binding */ loadEmployees),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ setSelectedEmployeesEmpty: () => (/* binding */ setSelectedEmployeesEmpty)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $(\"#selectHospital\"); // loads the select type from html\n selectUnitHTML = $(\"#selectDepartment\"); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n allHospitals.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $(\"<option>\").addClass(\"ideaCardFont\").val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $(\"#selectEmployee\");\n var selectedBox = $(\"#selectedEmployees\");\n var selectedOption = employeeList.find(\"option:selected\");\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find(\"option:selected\").remove();\n employeeList.prop(\"selectedIndex\", 0);\n}\nfunction getSelectedEmployees() {\n return selectedEmployees;\n}\nfunction setSelectedEmployeesEmpty() {\n selectedEmployees = [];\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $(\"<div>\").addClass(\"selectedEmployeeBubble\"); // Create a div element and add a class\n var textSpan = $(\"<span>\").addClass(\"ideaCardFont\").text(s); // Create a span element, set text, and add a class\n var deleteButton = $(\"<button>\").addClass(\"employeeDeleteButton\").text(\"X\"); // Create a button element, set text, and add a class\n deleteButton.on(\"click\", function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop(\"selectedIndex\", 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement(\"link\");\n linkelementCSS.rel = \"styleSheet\";\n linkelementCSS.href = \"initiateForbattringsarbete/initiateIdea.css\";\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement(\"link\");\n linkQuestionCSS.rel = \"styleSheet\";\n linkQuestionCSS.href = \"Make_Suggestion_Code/makeSuggestion.css\";\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = \"Activity_card_code/activitity_card.css\";\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch(\"initiateForbattringsarbete/initiateIdea.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\"#initiateIdeaWholePage\");\n //Eventlistenerbuttons:\n var createButton = tempContainer.querySelector(\"#createProjectFromSuggestionButton\");\n var selectEmployeeChangeSection = tempContainer.querySelector(\"#selectEmployee\");\n if (createButton) {\n createButton.addEventListener(\"click\", function () {\n return createProject(id);\n });\n } else {\n console.error(\"Error: 'createButton' not found\");\n }\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener(\"change\", assignedEmployer);\n } else {\n console.error(\"Error: 'changebutton' not found\");\n }\n if (specificElement) {\n console.error(\"spec element ok\");\n container.insertBefore(createButton, container.firstChild);\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject(id) {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormResourcesInput = document.getElementById(\"inputBoxFormResourcesInput\");\n var hospitalId = document.getElementById(\"selectHospital\");\n // alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\"\n //+ inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\"\n //+ selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\"\n //+ selectUnit.options[selectUnit.selectedIndex].value + \"\\n\"\n //+ selectedEmployees + \"\\n\"\n //+ inputBoxFormNameInput.value + \"\\n\"\n //+ inputBoxFormAreaInput.value + \"\\n\"\n //+ inputBoxFormContentInput.value + \"\\n\"\n //+ inputBoxFormPurposeInput.value + \"\\n\"\n //+ inputBoxFormMeasureInput.value + \"\\n\"\n //+ inputBoxFormIdeasInput.value + \"\\n\" );\n try {\n {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createImprovementWork)(null, inputBoxFormNameInput.value, \"Plan\", inputBoxFormContentInput.value, selectUnit.value,\n //unit id knows wich hospital it is refered to\n inputBoxFormPurposeInput.value, \"Green\", inputBoxFormAreaInput.value, inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value, selectedEmployees, inputBoxFormResourcesInput.value, hospitalId.value, inputBoxFormContentInput.value, inputBoxFormPurposeInput.value, undefined, inputBoxFormMeasureInput.value, undefined, inputBoxFormIdeasInput.value);\n }\n // Call the createSuggestion function with the obtained values\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadCurrentProjects)();\n } catch (_a) {\n alert(\"Error creating\");\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteSuggestion)(id);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Titel *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vad \\xE4r m\\xE5let med f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rslag p\\xE5 l\\xF6sning</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">F\\xF6rb\\xE4ttringarbetets resurser</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormResourcesInput\\\"\\n placeholder=\\\"Vilka resurser har f\\xF6rb\\xE4ttringsarbetet? Antal veckor, budget etc.\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -362,7 +306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 31;\n break;\n }\n _context4.next = 31;\n return (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n case 31:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./homePage.js */ \"./client/homePage.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImageHP\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFadedHP\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotesHP\\\">\\n <div class=\\\"upvoteDivHP\\\">\\n <svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"28\\\" height=\\\"28\\\" fill=\\\"currentColor\\\" class=\\\"bi bi-caret-up upvoteSymbol\\\" viewBox=\\\"0 0 16 16\\\">\\n <path d=\\\"M3.204 11h9.592L8 5.519 3.204 11zm-.753-.659 4.796-5.48a1 1 0 0 1 1.506 0l4.796 5.48c.566.647.106 1.659-.753 1.659H3.204a1 1 0 0 1-.753-1.659z\\\"/>\\n</svg> <div id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</div>\\n\\n </div>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Projekt</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('profilePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n addListner(myIdeaCards, container);\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = user.role;\n }\n projectContainer = document.getElementById(\"project-container\");\n if (projectContainer) {\n (0,_homePage_js__WEBPACK_IMPORTED_MODULE_2__.getProjects)(projectContainer, listenersLoaded, user.id);\n }\n case 29:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n console.log(expandedDiv);\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n });\n}\nvar projectCards = [];\n// async function getProjects(\n// selectElement: Element,\n// listenersLoaded: boolean,\n// improvementWorks: any[]\n// ) {\n// let id = 0;\n// projectCards = [];\n// improvementWorks.forEach(async (improvementWork) => {\n// let title = improvementWork.name;\n// let department = await getObjectById(\"unit\", improvementWork.unitId);\n// let projectLeader = await getImprovementWorkResponsible(improvementWork.id);\n// if (department) {\n// let card = new projectCard(\n// id,\n// projectLeader.firstName + \" \" + projectLeader.lastName,\n// department.name,\n// title,\n// improvementWork.content,\n// improvementWork.id,\n// improvementWork.currentStage,\n// improvementWork.dateStarted,\n// improvementWork.endDate,\n// improvementWork.completed,\n// );\n// projectCards.push(card);\n// let cardHTML = card.generateHTML();\n// let div = document.createElement(\"div\");\n// div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n// div.innerHTML = cardHTML;\n// if (!selectElement) return;\n// selectElement.appendChild(div); // Stop if the container isn't found\n// addEventListener(improvementWork.id, card);\n// // Display end date for completed projects\n// if (improvementWork.completed) {\n// const datesDiv = document.getElementById(\n// \"ongoingCardDatesCurrentProjects\" + improvementWork.id\n// );\n// if (datesDiv) {\n// datesDiv.innerText +=\n// \" till \" + formatDate(improvementWork.endDate);\n// }\n// }\n// // Display \"Avslutat\" for completed projects\n// const stageDiv = document.getElementById(\n// \"currentStageLetter\" + improvementWork.id\n// );\n// if (stageDiv) {\n// if (improvementWork.completed) {\n// stageDiv.innerText = \"Avslutat\";\n// stageDiv.style.fontSize = \"25px\";\n// stageDiv.style.marginLeft = \"5px\";\n// stageDiv.style.marginTop = \"30px\";\n// } else if (improvementWork.currentStage == \"Plan\") {\n// console.log(\"hej\");\n// stageDiv.innerHTML = \"P\";\n// } else if (improvementWork.currentStage == \"Do\") {\n// stageDiv.innerHTML = \"D\";\n// } else if (improvementWork.currentStage == \"Study\") {\n// stageDiv.innerText = \"S\";\n// } else if (improvementWork.currentStage == \"Act\") {\n// stageDiv.innerText = \"A\";\n// }\n// }\n// id++;\n// } else {\n// console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n// }\n// });\n// }\n//<p id=\"ongoingSeeDetailsButton${this.projectId}\" class = \"moreInfoClass\">> Mer information</p>\n\n//# sourceURL=webpack://c3/./client/profilePage.js?"); /***/ }), @@ -372,15 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, time, formatdateStarted, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n time = document.getElementById(\"pTime\");\n if (improvementWork.completed) {\n if (improvementWork.endDate instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n time.textContent = \"Förbättringsarbetet avslutades: \" + formatDate(improvementWork.endDate);\n } else {\n console.error(\"Inte en Timestamp\");\n }\n } else {\n formatdateStarted = timestamptoDate(improvementWork.dateStarted);\n time.textContent = \"Tid sen startat förbättringsarbete: \" + getDaysMonthYear(formatdateStarted);\n }\n _context5.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 12:\n aUnitArray = _context5.sent;\n _context5.next = 15;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 15:\n projectLeader = _context5.sent;\n _context5.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 18:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 30:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 36:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, link, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '../initiateForbattringsarbete/initiateIdea.css';\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(link);\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ formatDate: () => (/* binding */ formatDate),\n/* harmony export */ loadImprovementWorkTasks: () => (/* binding */ loadImprovementWorkTasks),\n/* harmony export */ loadMemberModal: () => (/* binding */ loadMemberModal),\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadProjectHeader: () => (/* binding */ loadProjectHeader),\n/* harmony export */ openTaskModal: () => (/* binding */ openTaskModal)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {}\nfunction loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var tasks, taskListElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getTasks)({\n improvementWorkId: projectId,\n stage: stage\n });\n case 2:\n tasks = _context2.sent;\n taskListElement = $(\"#\" + taskListId);\n modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId);\n if (taskListElement) {\n tasks.forEach(function (task) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var taskElement, textSpan, checkbox;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n taskElement = $(\"<li>\");\n textSpan = $(\"<span>\").text(task.name);\n checkbox = $(\"<input>\").attr(\"type\", \"checkbox\");\n if (task.completed) {\n checkbox.prop(\"checked\", true);\n }\n taskElement.append(textSpan, checkbox);\n taskElement.addClass(stageListClassName);\n taskElement.on(\"click\", function () {\n var startDateFormatted = formatDate(task.startDate);\n var endDateFormatted = formatDate(task.deadlineDate);\n openTaskModal(task.name, task.content, task.id, startDateFormatted, endDateFormatted, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId);\n });\n checkbox.on(\"click\", function (event) {\n event.stopPropagation();\n if (checkbox.prop(\"checked\")) {\n console.log(\"Checkbox is checked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: true\n });\n } else {\n console.log(\"Checkbox is unchecked.\");\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", task.id, {\n completed: false\n });\n }\n });\n taskListElement.append(taskElement); // Stop if the container isn't found\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n } else {\n console.log(\"Task container not found\");\n }\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//Opens modal for a task\nfunction openTaskModal(taskTitle, taskContent, taskId, taskStart, taskEnd, taskModalId, taskTitleId, taskContentId, taskStartDateId, taskEndDateId) {\n var taskModal = document.getElementById(taskModalId);\n var title = document.getElementById(taskTitleId);\n var content = document.getElementById(taskContentId);\n var startDate = document.getElementById(taskStartDateId);\n var endDate = document.getElementById(taskEndDateId);\n if (taskModal) {\n taskModal.setAttribute(\"data-task-id\", taskId);\n if (title && content && startDate && endDate) {\n title.value = \"\";\n content.value = \"\";\n startDate.value = \"\";\n endDate.value = \"\";\n if (taskTitle !== \"\" || taskContent !== \"\" || taskStart !== \"\" || taskEnd !== \"\") {\n title.value = taskTitle;\n content.value = taskContent;\n startDate.value = taskStart;\n endDate.value = taskEnd;\n }\n }\n taskModal.style.display = \"block\";\n }\n}\n//Adds eventlistener to close modal\nfunction modalEventListeners(projectId, stage, stageListClassName, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, saveBtnId, deleteBtnId) {\n var closeButton = document.getElementById(closeBtnId);\n var taskModal = document.getElementById(taskModalId);\n var saveButton = document.getElementById(saveBtnId);\n var deleteButton = document.getElementById(deleteBtnId);\n if (closeButton && taskModal) {\n var closeBtnListener = closeButton.hasAttribute(\"data-has-event-listener\");\n if (!closeBtnListener) {\n closeButton.setAttribute(\"data-has-event-listener\", \"true\");\n closeButton.addEventListener(\"click\", function () {\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (saveButton && taskModal) {\n var saveBtnListener = saveButton.hasAttribute(\"data-has-event-listener\");\n if (!saveBtnListener) {\n saveButton.setAttribute(\"data-has-event-listener\", \"true\");\n saveButton.addEventListener(\"click\", function () {\n createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n\n if (deleteButton && taskModal) {\n var deleteBtnListener = deleteButton.hasAttribute(\"data-has-event-listener\");\n if (!deleteBtnListener) {\n deleteButton.setAttribute(\"data-has-event-listener\", \"true\");\n deleteButton.addEventListener(\"click\", function () {\n deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId);\n taskModal.style.display = \"none\"; //Closes modal\n });\n }\n }\n}\n\nfunction createNewOrSaveTask(projectId, stage, stageListClassName, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, taskListId, closeBtnId, saveBtnId, deleteBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var modalElement, titleElement, deadlineElement, startElement, contentElement, taskId, improvementWork, deadline, startDate, listElement, _deadline, _startDate, _listElement;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n //title: string, deadline : Date, startDate: Date, stage: string, content: string\n modalElement = document.getElementById(taskModalId);\n titleElement = document.getElementById(taskTitleId);\n deadlineElement = document.getElementById(taskEndDateId);\n startElement = document.getElementById(taskStartDateId);\n contentElement = document.getElementById(taskContentId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!(taskId === \"\")) {\n _context3.next = 13;\n break;\n }\n _context3.next = 9;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 9:\n improvementWork = _context3.sent;\n if (titleElement && contentElement && deadlineElement && startElement) {\n if (titleElement.value !== \"\", deadlineElement.value !== \"\", startElement.value !== \"\", contentElement.value !== \"\") {\n deadline = new Date(deadlineElement.value); //Date string to timestamp\n startDate = new Date(startElement.value); //Date string to timestamp\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createTaskOnImprovementWork)(null, projectId, titleElement.value, deadline, startDate, improvementWork.currentStage, contentElement.value);\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n } else {\n console.log(\"All input fields for the task where not filled in\");\n }\n } else {\n console.log(\"All input element where not found\");\n }\n _context3.next = 21;\n break;\n case 13:\n if (!taskId) {\n _context3.next = 21;\n break;\n }\n _deadline = new Date(deadlineElement.value); //Date string to timestamp\n _startDate = new Date(startElement.value); //Date string to timestamp\n _context3.next = 18;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateInstance)(\"task\", taskId, {\n name: titleElement.value,\n deadlineDate: _deadline,\n startDate: _startDate,\n content: contentElement.value\n });\n case 18:\n _listElement = document.getElementById(taskListId);\n _listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n //loadPage(projectId); //Loads tasks since updated ASK for help\n case 21:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction deleteTask(projectId, stage, stageListClassName, taskModalId, taskListId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId, closeBtnId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var modalElement, taskId, listElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n modalElement = document.getElementById(taskModalId);\n taskId = modalElement.getAttribute(\"data-task-id\");\n if (!taskId) {\n _context4.next = 8;\n break;\n }\n _context4.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.deleteInstance)(\"task\", taskId);\n case 5:\n listElement = document.getElementById(taskListId);\n listElement.innerHTML = \"\";\n loadImprovementWorkTasks(projectId, stage, stageListClassName, taskListId, closeBtnId, taskModalId, taskTitleId, taskEndDateId, taskStartDateId, taskContentId, saveBtnId, deleteBtnId);\n case 8:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10 && parseInt(day, 10) > 9) {\n return \"\".concat(year, \"-0\").concat(month, \"-\").concat(day);\n } else if (parseInt(month, 10) > 9 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-\").concat(month, \"-0\").concat(day);\n } else if (parseInt(month, 10) < 10 && parseInt(day, 10) < 10) {\n return \"\".concat(year, \"-0\").concat(month, \"-0\").concat(day);\n } else {\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day);\n }\n}\nfunction timestamptoDate(timestamp) {\n if (timestamp instanceof firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.Timestamp) {\n var date = timestamp.toDate();\n return date;\n } else {\n console.error(\"Invalid timestamp type.\");\n return null;\n }\n}\nfunction getDaysMonthYear(startDate) {\n var currentTime = new Date();\n if (startDate) {\n var millisecondsDifference = currentTime.getTime() - startDate.getTime();\n // Convert milliseconds to seconds\n var secondsDifference = millisecondsDifference / 1000;\n // Calculate years, months, and days\n var years = Math.floor(secondsDifference / (365.25 * 24 * 60 * 60));\n var remainingSeconds = secondsDifference % (365.25 * 24 * 60 * 60);\n var months = Math.floor(remainingSeconds / (30 * 24 * 60 * 60)); // Assuming 30 days per month\n var days = Math.floor(remainingSeconds % (30 * 24 * 60 * 60) / (24 * 60 * 60));\n return \" \".concat(years, \" \\xE5r, \").concat(months, \" m\\xE5nader, \").concat(days, \" dagar.\");\n } else {\n return \"Det finns inget startdatum registrerat\";\n }\n}\nfunction loadProjectHeader(improvementWork) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var loadingIndicators, titleP, aAreaElement, resources, aUnitArray, projectLeader, members, aProjectLeader, aMembers, userNames, aUnit, aUnitElement, hospitalArray, aHospital, aHospitalElement;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n // Show loading indicators\n loadingIndicators = document.querySelectorAll(\".loadingIndicator\");\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"block\";\n });\n titleP = document.getElementById(\"title\");\n titleP.textContent = improvementWork.name;\n aAreaElement = document.getElementById(\"pArea\");\n aAreaElement.textContent = improvementWork.area;\n resources = document.getElementById(\"pResources\");\n resources.textContent = improvementWork.resources;\n _context5.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({\n unitId: improvementWork.unitId\n });\n case 10:\n aUnitArray = _context5.sent;\n _context5.next = 13;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 13:\n projectLeader = _context5.sent;\n _context5.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWork.id);\n case 16:\n members = _context5.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = projectLeader.firstName + \" \" + projectLeader.lastName + \" (\" + projectLeader.email + \")\";\n aMembers = document.getElementById(\"pMembers\");\n userNames = members.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n //stop loding current members\n if (aUnitArray.length === 0) {\n console.log(\"Error loading the units.\");\n }\n aUnit = aUnitArray[0];\n aUnitElement = document.getElementById(\"pUnit\");\n aUnitElement.textContent = aUnit.name;\n _context5.next = 28;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({\n hospitalId: aUnit.hospitalId\n });\n case 28:\n hospitalArray = _context5.sent;\n if (hospitalArray.length === 0) {\n console.log(\"Error loading the hospitals.\");\n }\n aHospital = hospitalArray[0];\n aHospitalElement = document.getElementById(\"pHospital\");\n aHospitalElement.textContent = aHospital.name;\n // Close loading indicators\n loadingIndicators.forEach(function (indicator) {\n indicator.style.display = \"none\";\n });\n case 34:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getDivWithIdFromHTML(path, id) {\n // Returning a Promise\n return fetch(path).then(function (response) {\n return response.text();\n }).then(function (html) {\n // Create a temporary container\n var container = document.createElement(\"div\");\n container.innerHTML = html;\n // Get the modal content from the container\n var element = container.querySelector(id);\n return element;\n })[\"catch\"](function (error) {\n console.error(\"Error loading modal content:\", error);\n return null;\n });\n}\nfunction loadMemberModal(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var modalContent, closeModal, saveModal, selectEmployeeChangeSection, upperCloseButton, lowerCloseButton, selectEmployeeSaveButton;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getDivWithIdFromHTML('../projectPage/addMemberModal.html', '#addMemberModal');\n case 2:\n modalContent = _context7.sent;\n //clear selected employees\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.setSelectedEmployeesEmpty)();\n if (modalContent) {\n closeModal = function closeModal() {\n if (modalContent) {\n $(modalContent).modal('hide');\n $('#container-fluid').find(modalContent).remove();\n // Clear event listeners\n selectEmployeeChangeSection.removeEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n upperCloseButton.removeEventListener('click', closeModal);\n lowerCloseButton.removeEventListener('click', closeModal);\n selectEmployeeSaveButton.removeEventListener('click', saveModal);\n }\n };\n saveModal = function saveModal() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var newMemberList, newProjectLeaderElement, newProjectLeaderId, newProjectLeaderUser, aProjectLeader, userMemberArray, aMembers, userNames;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n console.log(\"inne i save modal\");\n newMemberList = (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.getSelectedEmployees)();\n console.log(newMemberList);\n newProjectLeaderElement = document.getElementById(\"projectLeader\");\n newProjectLeaderId = newProjectLeaderElement.options[newProjectLeaderElement.selectedIndex].value;\n _context6.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.updateImprovementWorkMembers)(projectId, newProjectLeaderId, newMemberList);\n case 7:\n closeModal();\n //loadProjectHeader(improvementWork);\n _context6.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(projectId);\n case 10:\n newProjectLeaderUser = _context6.sent;\n aProjectLeader = document.getElementById(\"pLeader\");\n aProjectLeader.textContent = \"\";\n aProjectLeader.textContent = newProjectLeaderUser.firstName + \" \" + newProjectLeaderUser.lastName + \" (\" + newProjectLeaderUser.email + \")\";\n _context6.next = 16;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(projectId);\n case 16:\n userMemberArray = _context6.sent;\n aMembers = document.getElementById(\"pMembers\");\n aMembers.textContent = \"\";\n userNames = userMemberArray.map(function (member) {\n return \"\".concat(member.firstName, \" \").concat(member.lastName);\n });\n aMembers.textContent = userNames.join(', ');\n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n };\n $('#container-fluid').append(modalContent);\n $(modalContent).modal('show');\n selectEmployeeChangeSection = document.querySelector('#selectEmployee');\n upperCloseButton = modalContent.querySelector('#upperCloseMemberModal');\n lowerCloseButton = modalContent.querySelector('#lowerCloseMemberModal');\n selectEmployeeSaveButton = document.querySelector('#selectEmployeeSaveButton');\n if (selectEmployeeChangeSection) {\n selectEmployeeChangeSection.addEventListener('change', _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer);\n }\n if (upperCloseButton || lowerCloseButton) {\n upperCloseButton.addEventListener('click', closeModal);\n lowerCloseButton.addEventListener('click', closeModal);\n }\n if (selectEmployeeSaveButton) {\n selectEmployeeSaveButton.addEventListener('click', saveModal);\n }\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.loadEmployees)();\n setPreselectedMembers(projectId);\n }\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n// Your async function to set preselected members\nfunction setPreselectedMembers(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var projectLeader, members, selectProjectLeaderHTML, selectEmployeeHTML;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWorkId);\n case 2:\n projectLeader = _context8.sent;\n _context8.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsersForImprovementWork)(improvementWorkId);\n case 5:\n members = _context8.sent;\n selectProjectLeaderHTML = $('#projectLeader');\n selectEmployeeHTML = $('#selectEmployee');\n selectProjectLeaderHTML.find('option').each(function () {\n if ($(this).val() == projectLeader.id) {\n $(this).prop('selected', true);\n return false;\n }\n });\n members.forEach(function (member) {\n selectEmployeeHTML.find('option').each(function () {\n if ($(this).val() == member.id) {\n $(this).prop('selected', true);\n (0,_initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_2__.assignedEmployer)();\n return false; // This will exit the inner each loop\n }\n });\n });\n case 10:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPage.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), @@ -390,15 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n alert(\"hej\");\n if (!completed) {\n alert(\"not completed\");\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n alert(\"finds element\");\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-primary\");\n iterationButton.classList.add(\"btn\", \"btn-primary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'toCurrentProjects')) {\n _context3.next = 7;\n break;\n }\n checkInputFields(projectId, \"formPageA\");\n _context3.next = 39;\n break;\n case 7:\n if (!(target.id === 'nolansToP')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 39;\n break;\n case 11:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 39;\n break;\n case 15:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 19;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 39;\n break;\n case 19:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 23;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 39;\n break;\n case 23:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 27;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 39;\n break;\n case 27:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 38;\n break;\n }\n _context3.next = 30;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 30:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 35;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 36;\n break;\n case 35:\n alert(\"Document limit already reached for this project\");\n case 36:\n _context3.next = 39;\n break;\n case 38:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 39:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n case 14:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toCurrentProjects');\n if (container) {\n _context4.next = 5;\n break;\n }\n return _context4.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Act\", projectId);\n fetch('projectPage/projectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n _context4.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n container.addEventListener('click', function (event) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var target, pdfInput, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n target = event.target; // Type assertion\n pdfInput = document.getElementById('pdfInput');\n pdfLinkContainer = document.getElementById('pdfLink');\n if (!(target.id === 'nolansToP')) {\n _context3.next = 7;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n _context3.next = 35;\n break;\n case 7:\n if (!(target.id === 'nolansToG')) {\n _context3.next = 11;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n _context3.next = 35;\n break;\n case 11:\n if (!(target.id === 'nolansToS')) {\n _context3.next = 15;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n _context3.next = 35;\n break;\n case 15:\n if (!(target.id === \"saveEditBtnA\")) {\n _context3.next = 19;\n break;\n }\n saveImprovementWorkEditA(projectId);\n _context3.next = 35;\n break;\n case 19:\n if (!(target.id === \"addMemberButton\")) {\n _context3.next = 23;\n break;\n }\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadMemberModal)(projectId);\n _context3.next = 35;\n break;\n case 23:\n if (!(target.id === \"uploadButton\")) {\n _context3.next = 34;\n break;\n }\n _context3.next = 26;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 26:\n _context3.t0 = _context3.sent.length;\n if (!(_context3.t0 <= 5)) {\n _context3.next = 31;\n break;\n }\n pdfInput.addEventListener('change', function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var file, reader, tempUrl;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (!(this.files && this.files[0])) {\n _context2.next = 16;\n break;\n }\n file = this.files[0];\n reader = new FileReader();\n tempUrl = URL.createObjectURL(file);\n _context2.prev = 4;\n _context2.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.createdDocumentInKnowledgeBank)(tempUrl, file.name, projectId);\n case 7:\n _context2.next = 9;\n return addDocumentsToPage(projectId);\n case 9:\n _context2.next = 14;\n break;\n case 11:\n _context2.prev = 11;\n _context2.t0 = _context2[\"catch\"](4);\n console.error('Error uploading file and adding document to Firestore:', _context2.t0);\n case 14:\n reader.onload = function (e) {\n var target = e.target;\n if (target.result && pdfLinkContainer) {\n var fileName = file.name;\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(target.result, \"\\\" target=\\\"_blank\\\">\").concat(fileName, \"</a>\");\n }\n };\n reader.readAsDataURL(file);\n case 16:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[4, 11]]);\n }));\n });\n _context3.next = 32;\n break;\n case 31:\n alert(\"Document limit already reached for this project\");\n case 32:\n _context3.next = 35;\n break;\n case 34:\n if (target.id === \"new-task-button-a\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-a', 'task-title-a', 'task-content-a', 'task-start-a', 'task-end-a');\n }\n case 35:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n loadImprovementWorkDataPageA(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadImprovementWorkTasks)(projectId, \"Act\", 'tasksStageA', 'tasksA', 'close-task-modal-a', 'task-modal-a', 'task-title-a', 'task-end-a', 'task-start-a', 'task-content-a', 'save-task-button-a', 'delete-task-button-a');\n case 12:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addDocumentsToPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var documents, i, pdfLinkContainer;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getDocumentsByImprovementWork)(projectId);\n case 2:\n documents = _context5.sent;\n console.log(documents);\n for (i = 0; i < documents.length; i++) {\n pdfLinkContainer = document.getElementById(\"pdfLink\".concat(i));\n if (pdfLinkContainer) {\n pdfLinkContainer.innerHTML = \"<a href=\\\"\".concat(documents[i].url, \"\\\" target=\\\"_blank\\\">\").concat(documents[i].name, \"</a>\");\n }\n }\n case 5:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWork, a1, a2, a3, a4, user, isManager;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context6.sent;\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n (0,_projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_2__.loadPauseRestartButton)(projectId, improvementWork.ongoing, \"left-content-div-a\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.loadProjectHeader)(improvementWork);\n loadInitiateAndFinalizeBtn(projectId, improvementWork.completed);\n case 15:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n _context7.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n case 4:\n if (!_context7.sent) {\n _context7.next = 9;\n break;\n }\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n return _context7.abrupt(\"return\", true);\n case 9:\n return _context7.abrupt(\"return\", false);\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context8.abrupt(\"return\", true);\n case 7:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction checkInputFields(projectId, formId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this2 = this;\n var form;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditA(projectId) //Returns true if successful\n .then(function (success) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n if (!(success === true)) {\n _context9.next = 9;\n break;\n }\n _context9.next = 3;\n return finalize(projectId);\n case 3:\n if (!_context9.sent) {\n _context9.next = 7;\n break;\n }\n updateStage(\"Finished\", projectId);\n _context9.next = 8;\n break;\n case 7:\n // TODO nicer error message\n alert(\"Du kan inte avsluta detta förbättringsarbetet\");\n case 8:\n ;\n case 9:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n } else {\n alert('Please fill in all required fields.');\n }\n case 2:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction loadInitiateAndFinalizeBtn(projectId, completed) {\n if (!completed) {\n var nolanModelElement = document.getElementById(\"projectPageNolandsModel\");\n //Creates buttons with classname, id, attribute and text\n var finalizeButton = document.createElement(\"button\");\n var iterationButton = document.createElement(\"button\");\n if (nolanModelElement) {\n finalizeButton.id = \"toCurrentProjects\";\n iterationButton.id = \"toCurrentProjects\";\n finalizeButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.classList.add(\"btn\", \"btn-secondary\");\n iterationButton.setAttribute('role', 'button');\n finalizeButton.setAttribute('role', 'button');\n finalizeButton.textContent = 'Avsluta Förbättringsarbete';\n iterationButton.textContent = 'En till iteration';\n }\n //Append buttons to html\n nolanModelElement.append(iterationButton);\n nolanModelElement.append(finalizeButton);\n //Eventlistener for button\n finalizeButton.addEventListener('click', function () {\n checkInputFields(projectId, \"formPageA\");\n ;\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -418,15 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -<<<<<<< HEAD -<<<<<<< HEAD -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); -======= eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n pauseRestartButton.id = 'startPauseButton';\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); ->>>>>>> a71e69be923d665ec72aa2337639e950493c761d -======= -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ loadPauseRestartButton: () => (/* binding */ loadPauseRestartButton)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Plan\", projectId);\n fetch('projectPage/projectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n checkInputFields(projectId, 'formPageP');\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n if (target.id === \"new-task-button-p\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.openTaskModal)(\"\", \"\", \"\", \"\", \"\", 'task-modal-p', 'task-title-p', 'task-content-p', 'task-start-p', 'task-end-p');\n }\n if (target.id === \"addMemberButton\") {\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadMemberModal)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadImprovementWorkTasks)(projectId, \"Plan\", 'tasksStageP', 'tasksP', 'close-task-modal-p', 'task-modal-p', 'task-title-p', 'task-end-p', 'task-start-p', 'task-content-p', 'save-task-button-p', 'delete-task-button-p');\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, p1, p2, p3, p4, p5, p6, p7, user, isManager;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n //const titleP = document.getElementById(\"title\") as HTMLTextAreaElement;\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\"); //titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n //Checks if user is manager\n user = localStorage.getItem('user');\n if (user) {\n isManager = JSON.parse(user)[0].manager;\n if (isManager) {\n loadPauseRestartButton(projectId, improvementWork.ongoing, \"left-content-div-p\"); //Loads pause/restart button into html\n }\n }\n\n (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_2__.loadProjectHeader)(improvementWork);\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n return _context3.abrupt(\"return\", true);\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n/*Loads restart/pause button for an improvement work\nTakes improvement work id and boolean if improvement work is ongoing as in parameters\n*/\nfunction loadPauseRestartButton(projectId, ongoing, divId) {\n var leftAreaElement = document.getElementById(divId);\n //Creates button with classname and text\n var pauseRestartButton = document.createElement(\"button\");\n if (ongoing) {\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n pauseRestartButton.className = \"pause-button\";\n } else if (!ongoing) {\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n pauseRestartButton.className = \"restart-button\";\n }\n //Append button to html\n leftAreaElement.append(pauseRestartButton);\n //Eventlistener for button\n pauseRestartButton.addEventListener('click', function () {\n var user = localStorage.getItem('user');\n if (user) {\n var userId = JSON.parse(user)[0].id;\n }\n //Sets ongoing to false if true and vice versa\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.startOrPauseImprovementWork)(userId, projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n if (pauseRestartButton.className === \"restart-button\") {\n //Changes button text to \"Pausa förbättringsarbete\"\n pauseRestartButton.className = \"pause-button\";\n pauseRestartButton.textContent = \"Pausa förbättringsarbete\";\n } else if (pauseRestartButton.className === \"pause-button\") {\n //Changes button text to \"Återuppta förbättringsarbete\"\n pauseRestartButton.className = \"restart-button\";\n pauseRestartButton.textContent = \"Återuppta förbättringsarbete\";\n }\n }\n });\n });\n}\nfunction checkInputFields(projectId, formId) {\n var form = document.getElementById(formId);\n if (form.checkValidity()) {\n saveImprovementWorkEditP(projectId) //Returns true if successful\n .then(function (success) {\n if (success === true) {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId); //Loads next page if save was successful\n }\n });\n } else {\n alert('Please fill in all required fields.');\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); ->>>>>>> dc75e13b45b93da8d607579b3e8ba51cbe2e01e9 /***/ }), diff --git a/client/dist/projectPageA.bundle.js b/client/dist/projectPageA.bundle.js index 4882d9b13e80c9c34e9fe6bff71392eb142b4063..23dfc7a6e4892fa260ae60c2b75d8e403d18d47c 100644 --- a/client/dist/projectPageA.bundle.js +++ b/client/dist/projectPageA.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ firebaseConfig: () => (/* binding */ firebaseConfig),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var p1 = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : \"\";\n var p2 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p3 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p4 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p5 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p6 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p7 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var g1 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g2 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g3 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g4 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g5 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var s1 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s2 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s3 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var a1 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a2 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a3 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a4 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0)\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 18:\n _context21.prev = 18;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 22:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 18]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 12;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 12:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 18:\n _context24.prev = 18;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 18]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ deleteSuggestion: () => (/* binding */ deleteSuggestion),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getDocumentsByImprovementWork: () => (/* binding */ getDocumentsByImprovementWork),\n/* harmony export */ getFilteredImprovementWorks: () => (/* binding */ getFilteredImprovementWorks),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateImprovementWorkMembers: () => (/* binding */ updateImprovementWorkMembers),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n// C3 solutions databasen - ska användas för P&S\nvar firebaseConfig = {\n apiKey: \"AIzaSyB7n9YIDCmeyzeZzteFnXqOUBijzEO59ls\",\n authDomain: \"backup-277c3.firebaseapp.com\",\n projectId: \"backup-277c3\",\n storageBucket: \"backup-277c3.appspot.com\",\n messagingSenderId: \"296015398098\",\n appId: \"1:296015398098:web:71e1d1ec2b0c370e5a590b\",\n measurementId: \"G-E933CXWWCG\"\n};\n//Backup databas - ska användas av R&D\n// const firebaseConfig = {\n// apiKey: \"AIzaSyAMfD8V0belL6GxbuoehL__6YTFZH4pyoc\",\n// authDomain: \"company3-backup.firebaseapp.com\",\n// projectId: \"company3-backup\",\n// storageBucket: \"company3-backup.appspot.com\",\n// messagingSenderId: \"820650717800\",\n// appId: \"1:820650717800:web:7557c7734ed59d3f7281dd\"\n// };\n//Bens egna reserv #nödfall\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, role, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n role: role,\n manager: manager,\n notes: \"\"\n });\n case 4:\n _context.next = 9;\n break;\n case 6:\n _context.prev = 6;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 6]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. JA\nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area, projectLeader,\n//Adding projectleader & members to the project\nmembers) {\n var resources = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : \"Inte definerat ännu\";\n var hospitalId = arguments.length > 11 ? arguments[11] : undefined;\n var p1 = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : \"\";\n var p2 = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : \"\";\n var p3 = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : \"\";\n var p4 = arguments.length > 15 && arguments[15] !== undefined ? arguments[15] : \"\";\n var p5 = arguments.length > 16 && arguments[16] !== undefined ? arguments[16] : \"\";\n var p6 = arguments.length > 17 && arguments[17] !== undefined ? arguments[17] : \"\";\n var p7 = arguments.length > 18 && arguments[18] !== undefined ? arguments[18] : \"\";\n var g1 = arguments.length > 19 && arguments[19] !== undefined ? arguments[19] : \"\";\n var g2 = arguments.length > 20 && arguments[20] !== undefined ? arguments[20] : \"\";\n var g3 = arguments.length > 21 && arguments[21] !== undefined ? arguments[21] : \"\";\n var g4 = arguments.length > 22 && arguments[22] !== undefined ? arguments[22] : \"\";\n var g5 = arguments.length > 23 && arguments[23] !== undefined ? arguments[23] : \"\";\n var s1 = arguments.length > 24 && arguments[24] !== undefined ? arguments[24] : \"\";\n var s2 = arguments.length > 25 && arguments[25] !== undefined ? arguments[25] : \"\";\n var s3 = arguments.length > 26 && arguments[26] !== undefined ? arguments[26] : \"\";\n var a1 = arguments.length > 27 && arguments[27] !== undefined ? arguments[27] : \"\";\n var a2 = arguments.length > 28 && arguments[28] !== undefined ? arguments[28] : \"\";\n var a3 = arguments.length > 29 && arguments[29] !== undefined ? arguments[29] : \"\";\n var a4 = arguments.length > 30 && arguments[30] !== undefined ? arguments[30] : \"\";\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n lowerCaseName: name.toLowerCase(),\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4,\n resources: resources,\n endDate: new Date(0),\n hospitalId: hospitalId\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 12;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n id = _improvementWorkRef.id;\n case 12:\n //adding the projectleader and users to the project\n addMemberToImprovementWork(projectLeader, id, false, true);\n members.forEach(function (member) {\n addMemberToImprovementWork(member, id, false, false);\n });\n _context2.next = 20;\n break;\n case 16:\n _context2.prev = 16;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 20:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 16]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n/**\n * async function deleteSuggestion(suggestionId: string): Promise<void> {\n try {\n const suggestionRef = doc(suggestionCollection, suggestionId);\n await deleteDoc(suggestionRef);\n } catch (error) {\n console.log(\"Error deleting suggestion: \", error);\n throw error;\n }\n}\n */\nfunction removeMemberFromImprovementWork(userHsaId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var constraints, q, querySnapshot, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n constraints = [];\n if (!(userHsaId && improvementWorkId)) {\n _context5.next = 16;\n break;\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context5.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context5.sent;\n if (querySnapshot.empty) {\n _context5.next = 14;\n break;\n }\n docSnapshot = querySnapshot.docs[0];\n _context5.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"userImprovementWork\", docSnapshot.id));\n case 13:\n console.log(\"userImprovementWork with id \", docSnapshot.id, \" deleted\");\n case 14:\n _context5.next = 17;\n break;\n case 16:\n console.log(\"Both improvementWorkId and userHsaId need to be provided!\");\n case 17:\n _context5.next = 23;\n break;\n case 19:\n _context5.prev = 19;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error removing member from improvementWork: \", _context5.t0);\n throw _context5.t0;\n case 23:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 19]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n completed: false\n };\n if (!taskId) {\n _context6.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context6.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context6.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context6.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context6.next = 17;\n break;\n case 13:\n _context6.prev = 13;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error creating task: \", _context6.t0);\n throw _context6.t0;\n case 17:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name, projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name,\n projectId: projectId\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context8.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context8.next = 11;\n break;\n case 7:\n _context8.prev = 7;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error adding document: \", _context8.t0);\n throw _context8.t0;\n case 11:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 7]]);\n }));\n}\nfunction getDocumentsByImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var q, querySnapshot, documents, _iterator, _step, _doc, documentId, documentDoc;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n console.log(\"Getting documents for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(knowledgeDocumentCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"projectId\", \"==\", improvementWorkId));\n _context9.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context9.sent;\n // Fetch each related improvementWork document\n documents = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context9.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context9.next = 19;\n break;\n }\n _doc = _step.value;\n documentId = _doc.data().id;\n _context9.next = 15;\n return getObjectById(\"knowledgeDocument\", documentId);\n case 15:\n documentDoc = _context9.sent;\n documents.push(documentDoc);\n case 17:\n _context9.next = 10;\n break;\n case 19:\n _context9.next = 24;\n break;\n case 21:\n _context9.prev = 21;\n _context9.t0 = _context9[\"catch\"](8);\n _iterator.e(_context9.t0);\n case 24:\n _context9.prev = 24;\n _iterator.f();\n return _context9.finish(24);\n case 27:\n return _context9.abrupt(\"return\", documents);\n case 30:\n _context9.prev = 30;\n _context9.t1 = _context9[\"catch\"](0);\n console.error(\"Error getting documents for improvmentwork: \", _context9.t1);\n throw _context9.t1;\n case 34:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n hospitalData = {\n name: name\n };\n if (!hospitalId) {\n _context10.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name\n };\n if (!unitId) {\n _context11.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context11.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context11.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context11.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context11.next = 17;\n break;\n case 13:\n _context11.prev = 13;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error creating unit: \", _context11.t0);\n throw _context11.t0;\n case 17:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context12.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context12.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context12.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context12.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context12.next = 17;\n break;\n case 13:\n _context12.prev = 13;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context12.t0);\n throw _context12.t0;\n case 17:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 13]]);\n }));\n}\nfunction deleteSuggestion(suggestionId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context13.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(suggestionRef);\n case 4:\n _context13.next = 10;\n break;\n case 6:\n _context13.prev = 6;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error deleting suggestion: \", _context13.t0);\n throw _context13.t0;\n case 10:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 6]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var suggestionRef, suggestionDoc;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context14.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(suggestionRef);\n case 4:\n suggestionDoc = _context14.sent;\n if (!(suggestionDoc.exists() && suggestionDoc.data().upvotes.includes(userHsaId))) {\n _context14.next = 11;\n break;\n }\n _context14.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayRemove)(userHsaId)\n });\n case 8:\n return _context14.abrupt(\"return\", false);\n case 11:\n _context14.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 13:\n return _context14.abrupt(\"return\", true);\n case 14:\n _context14.next = 20;\n break;\n case 16:\n _context14.prev = 16;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context14.t0);\n throw _context14.t0;\n case 20:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 16]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context15.sent;\n _context15.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context15.sent;\n _context15.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context15.next = 16;\n break;\n case 12:\n _context15.prev = 12;\n _context15.t0 = _context15[\"catch\"](0);\n console.log(\"Error creating comment: \", _context15.t0);\n throw _context15.t0;\n case 16:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context16.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context16.next = 11;\n break;\n case 7:\n _context16.prev = 7;\n _context16.t0 = _context16[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context16.t0);\n throw _context16.t0;\n case 11:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var userRef;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context17.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n notes: content,\n dateCreated: new Date()\n });\n case 4:\n _context17.next = 10;\n break;\n case 6:\n _context17.prev = 6;\n _context17.t0 = _context17[\"catch\"](0);\n console.log(\"Error updating document: \", _context17.t0);\n throw _context17.t0;\n case 10:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 6]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context18.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context18.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context18.abrupt(\"return\", result);\n case 10:\n _context18.prev = 10;\n _context18.t0 = _context18[\"catch\"](0);\n console.error(\"Error getting collection data\", _context18.t0);\n throw _context18.t0;\n case 14:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context19.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context19.sent;\n if (!docSnapshot.exists()) {\n _context19.next = 9;\n break;\n }\n return _context19.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context19.abrupt(\"return\", null);\n case 11:\n _context19.next = 17;\n break;\n case 13:\n _context19.prev = 13;\n _context19.t0 = _context19[\"catch\"](0);\n console.error(\"Error getting object\", _context19.t0);\n throw _context19.t0;\n case 17:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context20.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context20.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context20.abrupt(\"return\", comments);\n case 11:\n _context20.prev = 11;\n _context20.t0 = _context20[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context20.t0);\n throw _context20.t0;\n case 15:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n name = _ref2.name,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic,\n departmentId = _ref2.departmentId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n sortBy = \"name\";\n }\n if (departmentId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"departmentId\", \"==\", departmentId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context21.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", suggestions);\n case 19:\n _context21.prev = 19;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context21.t0);\n throw _context21.t0;\n case 23:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context22.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", hospitals);\n case 14:\n _context22.prev = 14;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context22.t0);\n throw _context22.t0;\n case 18:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n name = _ref4.name,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n console.log(\"inne i ifsatsen i databasen\");\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \">=\", name.toLowerCase()));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"lowerCaseName\", \"<=\", name.toLowerCase() + \"~\"));\n } else {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context23.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", improvementWorks);\n case 19:\n _context23.prev = 19;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context23.t0);\n throw _context23.t0;\n case 23:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 19]]);\n }));\n}\n// Gets improvementWorks where each field matches the union of elements in the input array for each fo the fields\nfunction getFilteredImprovementWorks(_ref5) {\n var patientRiskLevels = _ref5.patientRiskLevels,\n nolanStages = _ref5.nolanStages,\n units = _ref5.units,\n _ref5$ascendingDates = _ref5.ascendingDates,\n ascendingDates = _ref5$ascendingDates === void 0 ? false : _ref5$ascendingDates,\n completed = _ref5.completed,\n hospitalIds = _ref5.hospitalIds;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n console.log(\"Getting improvement works with the following constraints\", patientRiskLevels, nolanStages, units, ascendingDates, hospitalIds);\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (patientRiskLevels && patientRiskLevels.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"in\", patientRiskLevels));\n }\n if (nolanStages && nolanStages.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"in\", nolanStages));\n }\n if (units && units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"in\", units));\n }\n // If none of the array filters are provided, default to ordering by date.\n if (!patientRiskLevels.length && !nolanStages.length && !units.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n }\n // Handle filtering by completion status\n if (completed !== null && completed !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (hospitalIds && hospitalIds.length) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"in\", hospitalIds));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context24.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", improvementWorks);\n case 19:\n _context24.prev = 19;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error retrieving filtered improvementWorks: \", _context24.t0);\n throw _context24.t0;\n case 23:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context25.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context25.sent;\n if (!querySnapshot.empty) {\n _context25.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context25.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context25.abrupt(\"return\", owner);\n case 15:\n _context25.next = 20;\n break;\n case 17:\n _context25.prev = 17;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(_context25.t0);\n case 20:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var constraints, q, querySnapshot, responsibleId, responsible;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context26.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context26.sent;\n if (!querySnapshot.empty) {\n _context26.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context26.abrupt(\"return\", null);\n case 13:\n responsibleId = querySnapshot.docs[0].data().userHsaId;\n _context26.next = 16;\n return getObjectById(\"users\", responsibleId);\n case 16:\n responsible = _context26.sent;\n return _context26.abrupt(\"return\", responsible);\n case 18:\n _context26.next = 23;\n break;\n case 20:\n _context26.prev = 20;\n _context26.t0 = _context26[\"catch\"](0);\n console.log(_context26.t0);\n case 23:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 20]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref6) {\n var hsaId = _ref6.hsaId,\n name = _ref6.name,\n unitId = _ref6.unitId,\n _ref6$ascendingFirstN = _ref6.ascendingFirstNames,\n ascendingFirstNames = _ref6$ascendingFirstN === void 0 ? false : _ref6$ascendingFirstN,\n uid = _ref6.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context27.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context27.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context27.abrupt(\"return\", users);\n case 17:\n _context27.prev = 17;\n _context27.t0 = _context27[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context27.t0);\n throw _context27.t0;\n case 21:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 17]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref7) {\n var improvementWorkId = _ref7.improvementWorkId,\n stage = _ref7.stage,\n _ref7$ascendingDates = _ref7.ascendingDates,\n ascendingDates = _ref7$ascendingDates === void 0 ? false : _ref7$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context28.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context28.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context28.abrupt(\"return\", tasks);\n case 14:\n _context28.prev = 14;\n _context28.t0 = _context28[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context28.t0);\n throw _context28.t0;\n case 18:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref8) {\n var unitId = _ref8.unitId,\n hospitalId = _ref8.hospitalId,\n name = _ref8.name,\n _ref8$ascendingUnitNa = _ref8.ascendingUnitNames,\n ascendingUnitNames = _ref8$ascendingUnitNa === void 0 ? false : _ref8$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context29.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context29.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context29.abrupt(\"return\", units);\n case 15:\n _context29.prev = 15;\n _context29.t0 = _context29[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context29.t0);\n throw _context29.t0;\n case 19:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var q, querySnapshot, improvementWorks, _iterator2, _step2, _doc2, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"userHsaId\", \"==\", userHsaId));\n _context30.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context30.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context30.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context30.next = 19;\n break;\n }\n _doc2 = _step2.value;\n improvementWorkId = _doc2.data().improvementWorkId;\n _context30.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context30.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context30.next = 10;\n break;\n case 19:\n _context30.next = 24;\n break;\n case 21:\n _context30.prev = 21;\n _context30.t0 = _context30[\"catch\"](8);\n _iterator2.e(_context30.t0);\n case 24:\n _context30.prev = 24;\n _iterator2.f();\n return _context30.finish(24);\n case 27:\n return _context30.abrupt(\"return\", improvementWorks);\n case 30:\n _context30.prev = 30;\n _context30.t1 = _context30[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context30.t1);\n throw _context30.t1;\n case 34:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var q, querySnapshot, users, _iterator3, _step3, _doc3, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 4:\n querySnapshot = _context31.sent;\n // Fetch each related user document\n users = [];\n _iterator3 = _createForOfIteratorHelper(querySnapshot.docs);\n _context31.prev = 7;\n _iterator3.s();\n case 9:\n if ((_step3 = _iterator3.n()).done) {\n _context31.next = 18;\n break;\n }\n _doc3 = _step3.value;\n userHsaId = _doc3.data().userHsaId;\n _context31.next = 14;\n return getObjectById(\"users\", userHsaId);\n case 14:\n userDoc = _context31.sent;\n users.push(userDoc);\n case 16:\n _context31.next = 9;\n break;\n case 18:\n _context31.next = 23;\n break;\n case 20:\n _context31.prev = 20;\n _context31.t0 = _context31[\"catch\"](7);\n _iterator3.e(_context31.t0);\n case 23:\n _context31.prev = 23;\n _iterator3.f();\n return _context31.finish(23);\n case 26:\n return _context31.abrupt(\"return\", users);\n case 29:\n _context31.prev = 29;\n _context31.t1 = _context31[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context31.t1);\n throw _context31.t1;\n case 33:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 29], [7, 20, 23, 26]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context32.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context32.next = 11;\n break;\n case 7:\n _context32.prev = 7;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context32.t0);\n throw _context32.t0;\n case 11:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context34.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context34.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33);\n }));\n });\n _context34.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context34.next = 15;\n break;\n case 11:\n _context34.prev = 11;\n _context34.t0 = _context34[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context34.t0);\n throw _context34.t0;\n case 15:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee35$(_context35) {\n while (1) switch (_context35.prev = _context35.next) {\n case 0:\n _context35.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context35.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context35.next = 11;\n break;\n case 7:\n _context35.prev = 7;\n _context35.t0 = _context35[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context35.t0);\n throw _context35.t0;\n case 11:\n case \"end\":\n return _context35.stop();\n }\n }, _callee35, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee36$(_context36) {\n while (1) switch (_context36.prev = _context36.next) {\n case 0:\n _context36.prev = 0;\n _context36.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context36.sent;\n _context36.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context36.sent;\n if (!(!user || !user.manager)) {\n _context36.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context36.next = 19;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context36.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n return _context36.abrupt(\"return\", true);\n case 19:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n return _context36.abrupt(\"return\", false);\n case 21:\n _context36.next = 27;\n break;\n case 23:\n _context36.prev = 23;\n _context36.t0 = _context36[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context36.t0);\n throw _context36.t0;\n case 27:\n case \"end\":\n return _context36.stop();\n }\n }, _callee36, null, [[0, 23]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee37$(_context37) {\n while (1) switch (_context37.prev = _context37.next) {\n case 0:\n _context37.prev = 0;\n _context37.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context37.sent;\n _context37.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context37.sent;\n if (!(!user || !user.manager)) {\n _context37.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context37.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context37.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context37.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context37.next = 25;\n break;\n case 21:\n _context37.prev = 21;\n _context37.t0 = _context37[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context37.t0);\n throw _context37.t0;\n case 25:\n case \"end\":\n return _context37.stop();\n }\n }, _callee37, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee38$(_context38) {\n while (1) switch (_context38.prev = _context38.next) {\n case 0:\n _context38.prev = 0;\n _context38.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context38.sent;\n if (!(!user || !user.manager)) {\n _context38.next = 8;\n break;\n }\n return _context38.abrupt(\"return\", false);\n case 8:\n update = {\n completed: true,\n ongoing: false,\n endDate: new Date()\n };\n _context38.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n return _context38.abrupt(\"return\", true);\n case 12:\n _context38.next = 17;\n break;\n case 14:\n _context38.prev = 14;\n _context38.t0 = _context38[\"catch\"](0);\n return _context38.abrupt(\"return\", false);\n case 17:\n case \"end\":\n return _context38.stop();\n }\n }, _callee38, null, [[0, 14]]);\n }));\n}\nfunction getAddAndDeleteMembersLists(listA, listB) {\n var deleteList = listA.filter(function (element) {\n return !listB.includes(element);\n });\n var addList = listB.filter(function (element) {\n return !listA.includes(element);\n });\n return {\n \"delete\": deleteList,\n add: addList\n };\n}\nfunction updateImprovementWorkMembers(improvementWorkId, projectLeaderId, membersIdList) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {\n var currentProjectLeader, currentMembers, currentMembersId, differenceList, indexOfProjectLeader;\n return _regeneratorRuntime().wrap(function _callee39$(_context39) {\n while (1) switch (_context39.prev = _context39.next) {\n case 0:\n _context39.next = 2;\n return getImprovementWorkResponsible(improvementWorkId);\n case 2:\n currentProjectLeader = _context39.sent;\n if (!(currentProjectLeader.id === projectLeaderId)) {\n _context39.next = 6;\n break;\n }\n _context39.next = 11;\n break;\n case 6:\n _context39.next = 8;\n return removeMemberFromImprovementWork(improvementWorkId, currentProjectLeader.id);\n case 8:\n _context39.next = 10;\n return addMemberToImprovementWork(projectLeaderId, improvementWorkId, false, true);\n case 10:\n console.log(\"ledare\");\n case 11:\n _context39.next = 13;\n return getUsersForImprovementWork(improvementWorkId);\n case 13:\n currentMembers = _context39.sent;\n currentMembersId = [];\n currentMembers.forEach(function (member) {\n currentMembersId.push(member.id);\n });\n differenceList = getAddAndDeleteMembersLists(currentMembersId, membersIdList);\n console.log(\"delete \" + differenceList[\"delete\"]);\n console.log(\"add \" + differenceList.add);\n indexOfProjectLeader = differenceList[\"delete\"].indexOf(projectLeaderId);\n if (indexOfProjectLeader !== -1) {\n alert(\"Du kan inte ta bort projektledaren från ditt förbättringsarbete. För att göra detta byt projektledare först. Alla andra ändringar kommer genomföras.\");\n differenceList[\"delete\"].splice(indexOfProjectLeader, 1);\n }\n differenceList[\"delete\"].forEach(function (deleteId) {\n removeMemberFromImprovementWork(deleteId, improvementWorkId);\n });\n differenceList.add.forEach(function (addId) {\n addMemberToImprovementWork(addId, improvementWorkId, false, false);\n });\n case 23:\n case \"end\":\n return _context39.stop();\n }\n }, _callee39);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -206,7 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n var stageImages = {\n Act: \"../images/Hemsida_PGSA_A.png\",\n Study: \"../images/Hemsida_PGSA_S.png\",\n Do: \"../images/Hemsida_PGSA_G.png\",\n Plan: \"../images/Hemsida_PGSA_P.png\",\n Finished: \"path/to/finished-image.jpg\"\n };\n var stageKey = this.stage;\n // Check if the stage is directly a key in stageImages\n if (!stageImages[stageKey]) {\n // If not, try to map the Swedish stage to English using nolanStageMapping\n stageKey = nolanStageMapping[stageKey];\n }\n // Now get the imageUrl using the stageKey\n var imageUrl = stageImages[stageKey];\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"completed-page-\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetterCompletedProjects\\\" style=\\\"font-size: 25px; font-weight: bolder;\\n color: #845380;\\n position: inherit; margin-left: 5px; margin-top: 30px;\\\">Avslutat</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCompletedProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat((0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted), \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 7:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, card.projectId, card);\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ projectCard: () => (/* binding */ projectCard)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../projectPage/projectPage.js */ \"./client/projectPage/projectPage.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n//import { projectCard } from \"../currentProjects/currentProjects.js\"\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage, dateStarted, endDate, completed) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n this.dateStarted = dateStarted;\n this.endDate = endDate;\n this.completed = completed;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n // Set default styles for stageSymbol (P, D, S, A, Avslutat)\n var stageSymbol = \"\";\n var stageFontSize = \"50px\";\n var stageMarginLeft = \"35px\";\n var stageMarginTop = \"10px\";\n // Set projectDates to dateStarted\n var projectDates = (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.dateStarted);\n if (this.completed) {\n stageSymbol = \"Avslutat\";\n stageFontSize = \"25px\";\n stageMarginLeft = \"5px\";\n stageMarginTop = \"30px\";\n // Append endDate to projectDates\n projectDates += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(this.endDate);\n } else if (this.stage == \"Plan\") {\n stageSymbol = \"P\";\n } else if (this.stage == \"Do\") {\n stageSymbol = \"G\";\n } else if (this.stage == \"Study\") {\n stageSymbol = \"S\";\n } else if (this.stage == \"Act\") {\n stageSymbol = \"A\";\n }\n return \"\\n <div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: default;\\\" class=\\\"flex-container ongoingCard shadow\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div id=\\\"borderPinkFaded\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\">\\n <div id=\\\"currentStageLetter\").concat(this.projectId, \"\\\" style=\\n \\\"font-size: \").concat(stageFontSize, \"; \\n margin-left: \").concat(stageMarginLeft, \"; \\n margin-top: \").concat(stageMarginTop, \";\\n font-weight: \\n bolder;\\n color: #845380;\\n position: inherit; \\n \\\">\").concat(stageSymbol, \"</div>\\n </div>\\n </div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDatesCurrentProjects\").concat(this.projectId, \"\\\" style=\\\"font-size: 13px; font-style: italic; margin-top: 5px;\\\">\").concat(projectDates, \" </p>\\n </div>\\n <button id=\\\"completed-page-button-\").concat(this.projectId, \"\\\" data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton fs-6 text-white d-flex pb-2 pt-2\\\" role=\\\"button\\\" style=\\\"height: 10%; min-width: 15vw; white-space: nowrap; align-items: center; font-family:'Roboto', sans-serif;\\\">G\\xE5 till F\\xF6rb\\xE4ttringsarbetet</button>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <div id=\\\"completed-page-ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</div>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nvar projectCards = [];\nvar filteredImprovementWorks = [];\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, checkedHospitalIds, checkedUnitIds, checkedNolanStages, checkedPatientRiskLevels, ascendingDates, searchBar;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context6.next = 3;\n break;\n }\n return _context6.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = [];\n // Initialize empty lists of checked hospital and unit ids\n checkedHospitalIds = [];\n checkedUnitIds = [];\n checkedNolanStages = [];\n checkedPatientRiskLevels = [];\n ascendingDates = false;\n fetch(\"KnowledgeBank/completedProjects.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n var createHospitalCheckBoxContainer = tempContainer.querySelector(\"#hospitalSelection\");\n var createUnitCheckBoxContainer = tempContainer.querySelector(\"#unitSelection\");\n var createNolanStageCheckBoxContainer = tempContainer.querySelector(\"#nolanStageSelection\");\n var createPatientRiskLevelCheckBoxContainer = tempContainer.querySelector(\"#patientRiskLevelSelection\");\n var createOrderSelectionContainer = tempContainer.querySelector(\"#orderSelection\");\n if (createHospitalCheckBoxContainer) {\n createHospitalCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n checkboxes = createHospitalCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createHospitalCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedHospitalIds = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedHospitalIds.push(inputCheckbox.id);\n }\n });\n // Log all checked hospital IDs\n console.log(\"Checked hospitals:\", checkedHospitalIds);\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true,\n hospitalIds: checkedHospitalIds\n });\n case 7:\n filteredImprovementWorks = _context.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n // Future change: Only clear the unitIds for unchecked hospitals!\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"unitSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadUnits)(checkedHospitalIds);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n }\n if (createUnitCheckBoxContainer) {\n createUnitCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n checkboxes = createUnitCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createUnitCheckBoxContainer\");\n // Empty list of checked units\n checkedUnitIds = [];\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedUnitIds.push(inputCheckbox.id);\n }\n });\n _context2.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context2.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n }\n if (createNolanStageCheckBoxContainer) {\n createNolanStageCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n checkboxes = createNolanStageCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]'); // Empty list of checked hospitals\n checkedNolanStages = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedNolanStages.push(inputCheckbox.id);\n checkedNolanStages.push(nolanStageMapping[inputCheckbox.id]);\n console.log(\"checkedNolanStages: \", checkedNolanStages);\n }\n });\n _context3.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 5:\n filteredImprovementWorks = _context3.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 8:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n }\n if (createPatientRiskLevelCheckBoxContainer) {\n createPatientRiskLevelCheckBoxContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var checkboxes;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n checkboxes = createPatientRiskLevelCheckBoxContainer.querySelectorAll('input[type=\"checkbox\"]');\n console.log(\"createPatientRiskLevelCheckBoxContainer\");\n // Empty list of checked hospitals\n checkedPatientRiskLevels = [];\n // Array to store IDs of checked checkboxes\n checkboxes.forEach(function (checkbox) {\n // Ensure the checkbox is an HTMLInputElement\n var inputCheckbox = checkbox;\n // Check if the checkbox is checked and add its ID to the array\n if (inputCheckbox.checked) {\n checkedPatientRiskLevels.push(inputCheckbox.id);\n checkedPatientRiskLevels.push(patientRiskLevelMapping[inputCheckbox.id]);\n console.log(\"checkedPatientRiskLevels: \", checkedPatientRiskLevels);\n }\n });\n _context4.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getFilteredImprovementWorks)({\n patientRiskLevels: checkedPatientRiskLevels,\n nolanStages: checkedNolanStages,\n units: checkedUnitIds,\n completed: true\n });\n case 6:\n filteredImprovementWorks = _context4.sent;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n });\n }\n if (createOrderSelectionContainer) {\n createOrderSelectionContainer.addEventListener(\"change\", function (event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var inputCheckbox;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n inputCheckbox = event.target;\n ascendingDates = inputCheckbox.checked;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n sortProjects(container, listenersLoaded, ascendingDates);\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n });\n }\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n _context6.next = 12;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 12:\n filteredImprovementWorks = _context6.sent;\n console.log(\"Filtered improvementWorks: \", filteredImprovementWorks);\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n getProjects(container, listenersLoaded, filteredImprovementWorks);\n searchBar = document.getElementById(\"searchBarImprovement\");\n searchBar === null || searchBar === void 0 ? void 0 : searchBar.addEventListener(\"keydown\", function (event) {\n if (event.key === \"Enter\") {\n performSearch(searchBar, container);\n }\n });\n console.log(\"Loading hospitals\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.clearContent)(\"hospitalSelection\");\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadHospitals)();\n loadNolanStages();\n loadPatientRiskLevels();\n case 23:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction loadNolanStages() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var selectStageHTML, allStages;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n selectStageHTML = $(\"#nolanStageSelection\"); // loads the select type from html\n allStages = [\"Planera\", \"Göra\", \"Studera\", \"Agera\"];\n allStages.forEach(function (stage) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + stage + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">\" + stage + \"</label>\\n </div>\");\n selectStageHTML.append(generatedElement);\n console.log(\"Adding HTML for for stage \", stage);\n });\n case 3:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nfunction loadPatientRiskLevels() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var selectPatientRiskLevelHTML, allRiskLevels;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n selectPatientRiskLevelHTML = $(\"#patientRiskLevelSelection\"); // loads the select type from html\n allRiskLevels = [\"Grön\", \"Blå\", \"Gul\", \"Röd\"];\n allRiskLevels.forEach(function (riskLevel) {\n var generatedElement = document.createRange().createContextualFragment(\"\\n <div class=\\\"form-check\\\">\\n <input class=\\\"form-check-input\\\" type=\\\"checkbox\\\" value=\\\"\\\" id=\\\"\" + riskLevel + \"\\\">\\n <label class=\\\"form-check-label\\\" for=\\\"flexCheckDefault\\\">Riskniv\\xE5 \" + riskLevel + \"</label>\\n </div>\");\n selectPatientRiskLevelHTML.append(generatedElement);\n console.log(\"Adding HTML for for risk level \", riskLevel);\n });\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8);\n }));\n}\nfunction sortProjects(selectElement, listenersLoaded, ascendingDates) {\n // Sort in reversed order if ascendingDates is true\n var cardsToIterate = ascendingDates ? _toConsumableArray(projectCards).reverse() : projectCards;\n // Loop through the saved array of cards and generate HTML for each card\n var _iterator = _createForOfIteratorHelper(cardsToIterate),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var card = _step.value;\n var cardHTML = card.generateHTML();\n var div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (!selectElement) return;\n addEventListener(listenersLoaded, card.projectId, card);\n selectElement.appendChild(div); // Stop if the container isn't found\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n}\nfunction getProjects(selectElement, listenersLoaded, improvementWorks) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var _this = this;\n var id;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n id = 0;\n projectCards = [];\n improvementWorks.forEach(function (improvementWork) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var title, department, projectLeaderHsaId, projectLeader, card, cardHTML, div, datesDiv;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n title = improvementWork.name;\n _context9.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", improvementWork.unitId);\n case 3:\n department = _context9.sent;\n _context9.next = 6;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorkResponsible)(improvementWork.id);\n case 6:\n projectLeaderHsaId = _context9.sent;\n console.log(\"leadr : \" + projectLeaderHsaId);\n _context9.next = 10;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", projectLeaderHsaId.id);\n case 10:\n projectLeader = _context9.sent;\n if (!department) {\n _context9.next = 26;\n break;\n }\n card = new projectCard(id, projectLeader.firstName + \" \" + projectLeader.lastName, department.name, title, improvementWork.content, improvementWork.id, improvementWork.currentStage, improvementWork.dateStarted, improvementWork.endDate, improvementWork.completed);\n projectCards.push(card);\n cardHTML = card.generateHTML();\n div = document.createElement(\"div\");\n div.className = \"projectCardCardDiv\"; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context9.next = 20;\n break;\n }\n return _context9.abrupt(\"return\");\n case 20:\n selectElement.appendChild(div); // Stop if the container isn't found\n addEventListener(listenersLoaded, improvementWork.id, card);\n if (improvementWork.completed) {\n datesDiv = document.getElementById(\"ongoingCardDatesCompletedProjects\" + improvementWork.id);\n if (datesDiv) {\n datesDiv.innerText += \" till \" + (0,_projectPage_projectPage_js__WEBPACK_IMPORTED_MODULE_3__.formatDate)(improvementWork.endDate);\n }\n }\n id++;\n _context9.next = 27;\n break;\n case 26:\n console.log(improvementWork.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist\n case 27:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9);\n }));\n });\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n //if (!listenersLoaded) {\n $(\"#completed-page-ongoingSeeDetailsButton\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var expandedDiv;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n expandedDiv = document.getElementById(\"expandedOngoingWorkCard\" + projectId);\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"completed-page-ongoingSeeDetailsButton\" + projectId);\n }\n case 2:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11);\n }));\n });\n $(\"#completed-page-button-\" + projectId).off(\"click\").on(\"click\", function () {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var tmp, currentStage;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"improvementWork\", projectId);\n case 2:\n tmp = _context12.sent;\n currentStage = tmp.currentStage;\n if (currentStage === \"Act\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === \"Study\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === \"Do\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === \"Plan\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === \"Finished\") {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n case 5:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12);\n }));\n });\n /*$(document).on(\"click\", \"#\" + projectId, async function (event) {\n let tmp = await getObjectById(\"improvementWork\", projectId);\n const currentStage = tmp.currentStage;\n const element = event.target as HTMLElement;\n if (element.classList.contains(\"moreInfoClass\")) {\n const expandedDiv = document.getElementById(\n \"expandedOngoingWorkCard\" + projectId\n );\n if (expandedDiv && expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n } else {\n card.closeMoreInfo(\n `expandedOngoingWorkCard` + projectId,\n `ongoingSeeDetailsButton` + projectId\n );\n }\n } else if (element.classList.contains(\"projectButton\")) {\n document.removeEventListener(\"click\", event.target);\n if (currentStage === \"Act\") {\n loadProjectPageA(projectId);\n } else if (currentStage === \"Study\") {\n loadProjectPageS(projectId);\n } else if (currentStage === \"Do\") {\n loadProjectPageG(projectId);\n } else if (currentStage === \"Plan\") {\n loadProjectPageP(projectId);\n } else if (currentStage === \"Finished\") {\n loadProjectPageP(projectId);\n }\n }\n });*/\n // }\n case 2:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13);\n }));\n}\nvar patientRiskLevelMapping = {\n Grön: \"Green\",\n Blå: \"Blue\",\n Gul: \"Yellow\",\n Röd: \"Red\"\n};\nvar nolanStageMapping = {\n Planera: \"Plan\",\n Göra: \"Do\",\n Studera: \"Study\",\n Agera: \"Act\"\n};\nfunction performSearch(searchBar, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var inputValue, query, matchedStage;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n inputValue = searchBar.value; //make first character uppercase\n inputValue = inputValue.toLowerCase();\n console.log(\"Search query:\", inputValue);\n // Remove each element\n projectCards = [];\n query = {};\n query.completed = true;\n (0,_ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.removeCardsFromDiv)(\"div.projectCardCardDiv\");\n if (inputValue !== \"\") {\n matchedStage = Object.keys(nolanStageMapping).find(function (stage) {\n return stage.toLowerCase().includes(inputValue.toLowerCase());\n });\n if (matchedStage) {\n query.nolanStage = nolanStageMapping[matchedStage];\n } else {\n query.name = inputValue;\n }\n }\n console.log(\"query:\", query);\n _context14.next = 11;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)(query);\n case 11:\n filteredImprovementWorks = _context14.sent;\n _context14.next = 14;\n return getProjects(container, true, filteredImprovementWorks);\n case 14:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage(completedProjectsListenersAdded);\n if (!completedProjectsListenersAdded) {\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n }\n completedProjectsListenersAdded = true;\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Välkommen tillbaka!\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(currentProjectsListenersAdded); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadMyProfilePage() {\n clearContent();\n setTitle(\"Din Profil\");\n _profilePage_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(); //fix containers\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page\n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n//BUtton hover handling\nfunction buttonHoverHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var allButtons, buttons, profDropButton, logoButton, logOutButton, submitButton, ideaBankButton;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n allButtons = document.querySelectorAll(\".nav-link\");\n buttons = Array.from(allButtons).filter(function (button) {\n return button.id !== \"regionOstergotlandImage\" && button.id !== \"log-out-button\" && button.id !== \"profileDropdown\" && button.id !== \"suggestionButton\";\n });\n profDropButton = document.getElementById(\"profileDropdown\");\n logoButton = document.getElementById(\"regionOstergotlandImage\");\n logOutButton = document.getElementById(\"log-out-button\");\n submitButton = document.getElementById(\"suggestionButton\");\n ideaBankButton = document.getElementById(\"ideaBankView\");\n buttons.forEach(function (button) {\n button.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n button.classList.add(\"active\");\n });\n });\n if (logoButton) {\n logoButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (logOutButton) {\n logOutButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (profDropButton) {\n profDropButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n });\n }\n if (submitButton && ideaBankButton) {\n submitButton.addEventListener(\"click\", function () {\n buttons.forEach(function (b) {\n return b.classList.remove(\"active\");\n });\n ideaBankButton.classList.add(\"active\");\n });\n }\n case 12:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hideElement: () => (/* binding */ hideElement),\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadIdeaBank: () => (/* binding */ loadIdeaBank),\n/* harmony export */ loadInitiatePage: () => (/* binding */ loadInitiatePage),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS),\n/* harmony export */ loggedIn: () => (/* binding */ loggedIn)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _profilePage_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../profilePage.js */ \"./client/profilePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\nvar completedProjectsListenersAdded = false;\n//Function to make all button-hover-effects work\nbuttonHoverHandler();\n//Listeners for all the different pages\n$(\"#ideaBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadIdeaBank();\n});\n$(\"#regionOstergotlandImage\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfile();\n});\n$(\"#log-out-button\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n logOut();\n});\n$(\"#settingsView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSettings();\n});\n$(\"#knowledgeBankView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadKnowledgeBank();\n});\n$(\"#profileView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#profileDropdown\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadMyProfilePage();\n});\n$(\"#supportView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSupport();\n});\n$(\"#currentProjects\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadCurrentProjects();\n});\n$(\"#suggestionView\").off(\"click\").on(\"click\", function (e) {\n e.preventDefault();\n loadSuggestionPage();\n});\n$(\"#button-login\").off(\"click\").on(\"click\", function (e) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n e.preventDefault();\n _context.next = 3;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_21__.handleLogin();\n case 3:\n if (!_context.sent) {\n _context.next = 6;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n});\n//if (x!true){ x = false}\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\n//help function after logging in successfully\nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\n//Function that logs out the user\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Förbättringsförslag\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Metoder & Teorier\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n console.log(\"###################################laddas\");\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _K